PHP code example of rollerworks / metadata-doctrine-cache
1. Go to this page and download the library: Download rollerworks/metadata-doctrine-cache library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rollerworks / metadata-doctrine-cache example snippets
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache\ChainCache;
use Doctrine\Common\Cache\FilesystemCache;
use Rollerworks\Component\Metadata\CacheableMetadataFactory;
use Rollerworks\Component\Metadata\Cache\Validator\AlwaysFreshValidator;
use Rollerworks\Component\Metadata\Cache\ArrayCache;
$cacheDirectory = ...;
// The Doctrine cache library.
$doctrineCache = new ChainCache(
[
// Include the ArrayCache as the ChainCache will populate all the previous cache layers.
// So if the `FilesystemCache` has a match it will populate the faster ArrayCache.
new ArrayCache(),
// Saves the cache in the filestem.
new FilesystemCache($cacheDirectory),
]
);
// Rollerworks\Component\Metadata\Cache\CacheProvider
$cache = Rollerworks\Component\Metadata\Driver\Cache\DoctrineCache($doctrineCache);
// Rollerworks\Component\Metadata\Driver\MappingDriver
$driver = ...;
// Rollerworks\Component\Metadata\Cache\FreshnessValidator
$freshnessValidator = ...;
$metadataFactory = new CacheableMetadataFactory($driver, $doctrineCache, $freshnessValidator);