![]() | |
You can used this plugin (from PHP Reflect) only since CompatInfo 3.2 |
<?php use Bartlett\CompatInfo; use Bartlett\Reflect\Plugin\Cache\CachePlugin; $compatinfo = new CompatInfo; $compatinfo->addPlugin( new CachePlugin($cache) );
Where $cache
is an instance of object that must implement interface
Bartlett\Reflect\Plugin\Cache\CacheStorageInterface
.
![]() | |
Use the |
Use one of the most famous caching solution, provided by the Doctrine project.
<?php use Bartlett\CompatInfo; use Bartlett\Reflect\Plugin\Cache\CachePlugin; use Bartlett\Reflect\Plugin\Cache\DefaultCacheStorage; use Bartlett\Reflect\Cache\DoctrineCacheAdapter; use Doctrine\Common\Cache\FilesystemCache; $doctrineCache = new DoctrineCacheAdapter($backend); $cache = new DefaultCacheStorage($doctrineCache); $compatinfo = new CompatInfo; $compatinfo->addPlugin( new CachePlugin($cache) );
Where $backend
is an instance of object that must implement interface
Doctrine\Common\Cache\CacheProvider
.
Doctrine File backend to store your Reflect results in the local file system.
<?php use Bartlett\CompatInfo; use Bartlett\Reflect\Plugin\Cache\CachePlugin; use Bartlett\Reflect\Plugin\Cache\DefaultCacheStorage; use Bartlett\Reflect\Cache\DoctrineCacheAdapter; use Doctrine\Common\Cache\FilesystemCache; $backend = new FilesystemCache(sys_get_temp_dir() . '/bartlett/cache'); $doctrineCache = new DoctrineCacheAdapter($backend); $cache = new DefaultCacheStorage($doctrineCache); $compatinfo = new CompatInfo; $compatinfo->addPlugin( new CachePlugin($cache) );
In the source code above, we use the standard Doctrine File cache provider, and store results in the default system temporary directory ( see php sys_get_temp_dir() function ).