File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ # Namespaced PSR-6 cache pool
2+
3+ The namespaced cache pool is a special cache of the hierarchical cache architecture where it only uses one level
4+ of hierarchy. Use this when you provide a third party library with a PSR-6 cache pool to make sure you never
5+ get key conflicts or unexpected calls to ` CacheItemPoolInterface::clear() ` .
6+
7+ ``` php
8+ // Get a pool that supports hierarchy
9+ $client = new \Redis();
10+ $client->connect('127.0.0.1', 6379);
11+ $pool = new RedisCachePool($client);
12+
13+ // Decorate it with a NamesapcedPool
14+ $namespacedPool = new NamespacedCachePool($pool, 'acme');
15+
16+ $item = $namespacedPool->getItem('foo')->set('bar');
17+ $namespacedPool->save($item);
18+
19+ $namespacedPool->hasItem('foo'); // True
20+ $pool->hasItem('foo'); // False
21+ ```
22+
23+ Internally the ` NamespacedCachePool ` will prepend all keys with ` |acme| ` . Which means that the ` $pool `
24+ may access items in the namespace by doing the very same:
25+
26+ ``` php
27+ $pool->hasItem('|acme|foo'); // True
28+ ```
29+
30+ ## Symfony integration
31+
32+ If you are are using our bundles you may configure a service with as a namespaced pool by using the ` pool_namespace `
33+ configuration option.
34+
You can’t perform that action at this time.
0 commit comments