Using Cache service: comparison of v.3 vs v.4
Versions Compared
Old Version 3
changes.mady.by.user André Rømcke
Saved on Jan 21, 2016
compared with
New Version Current
changes.mady.by.user Dominika Kurek
Saved on Jan 22, 2016
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Using the internal cache service allows you to use a interface and an interface and to not have to care about if whether the system has been configured to place the cache in Memcached or on File system. And as eZ Platform requires that instances uses use a cluster-aware cache in Cluster setup, you can safely assume your cache is shared (and invalidated) across all web servers.
| Warning | ||
|---|---|---|
|
||
| Current implementation uses a caching library called Stash, via Stash-bundleStashBundle. We plan to move to a PSR-6 compatible cache service cable capable of supporting cache Tagging and multi get/set in the future, when that happens the interface of the cache service will change! |
| Note | ||
|---|---|---|
|
||
| When reusing the cache service within your own code, it is very important to not conflict with the cache keys used by others, hence . That is why the example of usage below starts with a unique "myApp" key for . For the namespace of your own cache, you must do the same! So never clear cache using the cache service without your key specified, otherwise you'll clear all cache. |
...
Via Dependency injection
In your symfony Symfony services configuration you can simply define that you require the "cache" service in your configuration like so:
...
Like any other service, it is also possible to get the "cache" service via container as well like so:
| Code Block | ||||
|---|---|---|---|---|
|
||||
/** @var $cacheService \Tedivm\StashBundle\Service\CacheService */
$cacheService = $container->get('exponential.cache_pool');
|
...
Clearing Persistence cache
Persistence cache uses a separate Cache Pool decorator which by design prefixes cache keys with "ez_spi", clearing . Clearing persistence cache can thus be done in the following way:
...
Comments
Add a comment