File tree 13 files changed +619
-295
lines changed
Filter options
13 files changed +619
-295
lines changed
Original file line number Diff line number Diff line change
1
+ .. index ::
2
+ single: Cache Pool
3
+ single: APC Cache, APCu Cache
4
+
5
+ APCu Cache Adapter
6
+ ==================
7
+
8
+ This adapter can increase the application performance very significantly,
9
+ because contents are cached in the shared memory of your server, which is much
10
+ faster than the file system. It requires to have installed and enabled the PHP
11
+ APCu extension. It's not recommended to use it when performing lots of write and
12
+ delete operations because it produces fragmentation in the APCu memory that can
13
+ degrade performance significantly::
14
+
15
+ use Symfony\Component\Cache\Adapter\ApcuAdapter;
16
+
17
+ $cache = new ApcuAdapter(
18
+ // the string prefixed to the keys of the items stored in this cache
19
+ $namespace = '',
20
+ // in seconds; applied to cache items that don't define their own lifetime
21
+ // 0 means to store the cache items indefinitely (i.e. until the APC memory is deleted)
22
+ $defaultLifetime = 0,
23
+ // if present, this string is added to the namespace to simplify the
24
+ // invalidation of the entire cache (e.g. when deploying the application)
25
+ $version = null
26
+ );
Original file line number Diff line number Diff line change
1
+ .. index ::
2
+ single: Cache Pool
3
+ single: Array Cache
4
+
5
+ Array Cache Adapter
6
+ ===================
7
+
8
+ This adapter is only useful for testing purposes because contents are stored in
9
+ memory and not persisted in any way. Besides, some features explained later are
10
+ not available, such as the deferred saves::
11
+
12
+ use Symfony\Component\Cache\Adapter\ArrayAdapter;
13
+
14
+ $cache = new ArrayAdapter(
15
+ // in seconds; applied to cache items that don't define their own lifetime
16
+ // 0 means to store the cache items indefinitely (i.e. until the current PHP process finishes)
17
+ $defaultLifetime = 0,
18
+ // if ``true``, the values saved in the cache are serialized before storing them
19
+ $storeSerialized = true
20
+ );
Original file line number Diff line number Diff line change
1
+ .. index ::
2
+ single: Cache Pool
3
+ single: Chain Cache
4
+
5
+ Chain Cache Adapter
6
+ ===================
7
+
8
+ This adapter allows to combine any number of the previous adapters. Cache items
9
+ are fetched from the first adapter which contains them. Besides, cache items are
10
+ saved in all the given adapters, so this is a simple way of creating a cache
11
+ replication::
12
+
13
+ use Symfony\Component\Cache\Adapter\ApcuAdapter;
14
+ use Symfony\Component\Cache\Adapter\ChainAdapter;
15
+ use Symfony\Component\Cache\Adapter\FilesystemAdapter;
16
+
17
+ $apcCache = new ApcuAdapter();
18
+ $fileCache = new FilesystemAdapter();
19
+
20
+ $cache = new ChainAdapter(array($apcCache, $fileCache));
21
+
22
+ When an item is not found in the first adapters but is found in the next ones,
23
+ the ``ChainAdapter `` ensures that the fetched item is saved in all the adapters
24
+ where it was missing. Since it's not possible to know the expiry date and time
25
+ of a cache item, the second optional argument of ``ChainAdapter `` is the default
26
+ lifetime applied to those cache items (by default it's ``0 ``).
Original file line number Diff line number Diff line change
1
+ .. index ::
2
+ single: Cache Pool
3
+ single: Doctrine Cache
4
+
5
+ Doctrine Cache Adapter
6
+ ======================
7
+
8
+ This adapter wraps any `Doctrine Cache `_ provider so you can use them in your
9
+ application as if they were Symfony Cache adapters::
10
+
11
+ use Doctrine\Common\Cache\SQLite3Cache;
12
+ use Symfony\Component\Cache\Adapter\DoctrineAdapter;
13
+
14
+ $sqliteDatabase = new \SQLite3(__DIR__.'/cache/data.sqlite');
15
+ $doctrineCache = new SQLite3Cache($sqliteDatabase, 'tableName');
16
+ $symfonyCache = new DoctrineAdapter($doctrineCache);
17
+
18
+ This adapter also defines two optional arguments called ``namespace `` (default:
19
+ ``'' ``) and ``defaultLifetime `` (default: ``0 ``) and adapts them to make them
20
+ work in the underlying Doctrine cache.
21
+
22
+ .. _`Doctrine Cache` : https://github.com/doctrine/cache
Original file line number Diff line number Diff line change
1
+ .. index ::
2
+ single: Cache Pool
3
+ single: Filesystem Cache
4
+
5
+ Filesystem Cache Adapter
6
+ ========================
7
+
8
+ This adapter is useful when you want to improve the application performance but
9
+ can't install tools like APCu or Redis in the server. This adapter stores the
10
+ contents as regular files in a set of directories on the local file system::
11
+
12
+ use Symfony\Component\Cache\Adapter\FilesystemAdapter;
13
+
14
+ $cache = new FilesystemAdapter(
15
+ // the subdirectory of the main cache directory where cache items are stored
16
+ $namespace = '',
17
+ // in seconds; applied to cache items that don't define their own lifetime
18
+ // 0 means to store the cache items indefinitely (i.e. until the files are deleted)
19
+ $defaultLifetime = 0,
20
+ // the main cache directory (the application needs read-write permissions on it)
21
+ // if none is specified, a directory is created inside the system temporary directory
22
+ $directory = null
23
+ );
You can’t perform that action at this time.
0 commit comments