Current implementation uses a caching library called Stash, via Stash-bundle. If this changes, then the configuration format will most likely change as well. Stash supports the following cache handlers: FileSystem, Memcache, APC, Sqlite, XCache and BlackHole.
The cache system is exposed as a "cache" service, and can be reused by any other service as described on the Persistence cache page.
During Setup wizard and manually using
ezpublish:configure console command a default configuration is generated currently using FileSystem, using
%kernel.cache_dir%/stash to store cache files.
The configuration is placed in ezpublish/config/ezpublish.yml, and looks like:
The default settings used during setup wizard as found in
This setting works across all installs and just caches objects within the same request thanks to the
inMemory: true setting.
If you want to change to another handler, see in Stash handlers configuration below for what kind of settings you have available.
Note for "inMemory" cache with long running scripts
inMemory caching with BlackHole or any other cache handler should not be used for long running scripts as it will over time return stale data, inMemory cache is not shared across requests/processes, so invalidation does not happen!
Multi repository setup
New in 5.2 is the possibility to select a specific Stash cache pool on a siteaccess or sitegroup level, the following example shows use in a sitegroup:
The "default" here refers to the name of the cache pool as specified in the stash configuration block shown above, if your install has several repositories (databases), then make sure every group of sites using different repositories also uses a different cache pool to avoid unwanted effects.
NB: We plan to make this more native in the future, so this setting will someday not be needed.
Stash handlers configuration
To check which cache settings are available for your installation, run the following command in your terminal :
This cache handler is using local filesystem, by default the Symfony cache folder, as this is per server, it does not support multi server (cluster) setups!
|The path where the cache is placed, default is |
|Number of times the cache key should be split up to avoid having to many files in each folder, default is 2.|
|The permissions of the cache file, default is 0660.|
|The permission of the cache file directories (see dirSplit), default is 0770.|
|Limit on how many key to path entries are kept in memory during execution at a time to avoid having to recalculate the path on key lookups, default 200.|
Algorithm used for creating paths, default
Issues with Microsoft Windows
If you are using a Windows OS, you may encounter an issue regarding long paths for cache directory name. The paths are long because Stash uses md5 to generate unique key that are sanitized really quickly.
Solution is to change the hash algorithm used by Stash.
This configuration is only recommended for Windows users.
Note : you can also define the path where you want the cache files to be generated.
This cache handler is using shard memory using APC's user cache feature, as this is per server, it does not support multi server (cluster) setups, unless you use PHP-FPM on a dedicated server (this way, user cache can be shared among all the workers in one pool).
As APC user cache is not shared between processes, it is not possible to clear the user cache from CLI, even if you set
apc.enable_cli to On.
Hence publishing content from a command line script won't let you properly clear SPI cache.
Please also note that the default value for
apc.shm_size is 128MB. However, 256MB is recommended for APC to work properly. For more details please refer to the APC configuration manual.
|The time to live of the cache in seconds, default set to 500 (8.3 minutes)|
|A namespace to prefix cache keys with to avoid key conflicts with other eZ Publish sites on same eZ Publish installation, default is |
This cache handler is using Memcached, a distributed caching solution, this is the only supported cache solution for multi server (cluster) setups!
Array of Memcached servers, with host/IP, port and weight
|A namespace to prefix cache keys with to avoid key conflicts with other eZ Publish sites on same eZ Publish installation (default is an empty string). |
Must be the same on all server with the same installation. See Memcached prefix_key option.
|default true. See Memcached compression option.|
|default false. See Memcached libketama_compatible option|
|default false. See Memcached buffer_writes option|
|default false. See Memcached binary_protocol option|
|default false. See Memcached no_block option|
|default false. See Memcached tcp_nodelay option|
|default 1000. See Memcached connection_timeout option|
|default 0. See Memcached retry_timeout option|
|default 0. See Memcached send_timeout option|
default 0. See Memcached recv_timeout option
|default 1000. See Memcached poll_timeout option|
|default false. See Memcached cache_lookups option|
|default 0. See PHP Memcached documentation |
|See Memcached socket_send_size option.|
|See Memcached socket_recv_size option.|
|See Memcached serializer option.|
|See Memcached hash option.|
Specifies the method of distributing item keys to the servers. See Memcached distribution option.
For in-depth information on the settings, see: http://php.net/Memcached
When using Memcache handler, it's strongly recommended to also use
inMemory cache (see example below).
This will help reducing network traffic between your webserver and your Memcached server.
Example with Memcache
Connection errors issue
If memcached may display connection errors when using the default (ascii) protocol, switch to binary protocol (in the stash configuration and memcached daemon) should resolve the issue.