Doctrine Cache AdapterEdit this page
Warning: You are browsing the documentation for Symfony 4.1, which is no longer maintained.
Read the updated version of this page for Symfony 7.0 (the current stable version).
This adapter wraps any class extending the Doctrine Cache abstract provider, allowing you to use these providers in your application as if they were Symfony Cache adapters.
This adapter expects a
instance as its first
parameter, and optionally a namespace and default cache lifetime as its second and
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
use Doctrine\Common\Cache\CacheProvider; use Doctrine\Common\Cache\SQLite3Cache; use Symfony\Component\Cache\Adapter\DoctrineAdapter; $provider = new SQLite3Cache(new \SQLite3(__DIR__.'/cache/data.sqlite'), 'youTableName'); $cache = new DoctrineAdapter( // a cache provider instance CacheProvider $provider, // a string prefixed to the keys of the items stored in this cache $namespace = '', // the default lifetime (in seconds) for cache items that do not define their // own lifetime, with a value 0 causing items to be stored indefinitely (i.e. // until the database table is truncated or its rows are otherwise deleted) $defaultLifetime = 0 );