Message-ID: <991100128.4284.1485862254833.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_4283_620785920.1485862254833" ------=_Part_4283_620785920.1485862254833 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Persistence cache configuration

Persistence cache configuration


=20 =20

Introduction

Tech Note

Current implementation uses a caching library called Stash, via <= a href=3D"https://github.com/tedivm/TedivmStashBundle" class=3D"external-li= nk" rel=3D"nofollow">Stash-bundle. If this changes, then the confi= guration format will most likely change as well. Stash= supports the following cache handlers: FileSystem<= span>, Memcache, APC, Sqlite, XCache and BlackHole.

Cache service

The cache system is exposed as a "cache" service, and can be reused by a= ny other service as described on the Persistence cache page.

Configuration

During Setup wizard and manually using ezpublish:configure&= nbsp;console command a default configuration is generated currently using FileSystem, using %kernel.cache_dir%/stash to = store cache files. It falls back to BlackHole, a non cac= hing cache handler.

The configuration is placed in ezpublish/config/ezpublish.yml, and looks= like:

Default ezpublish.yml
=20
stash:
    caches:
        default:
            handlers:
                - FileSystem
            inMemory: false
            registerDoctrineAdapter: false
=20

The default settings used during setup wizard as found in ezpublis= h/config/ezpublish_setup.yml:

ezpublish_setup.yml
=20
stash:
    caches:
        default:
            handlers:
                - BlackHole
            inMemory: true
            registerDoctrineAdapter: false
=20

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 below for what kind of set= tings you have available.

Note for multiple sites installation

As cache configuration is global to the application, it's currently not = possible to have different cache configuration by siteaccess. As such, when= having multiple websites using different content repositories, you must only use the BlackHole handler with inMem= ory caching:

=20
stash:
    caches:
        default:
            handlers: [BlackHole]
            inMemory: true
            registerDoctrineAdapter: false
=20

This will result to the same persistence cache strategy as in eZ Publish= 4.x.

Note for "inMemory" cache with long running scripts

Use of inMemory caching with BlackHole or any other cache h= andler should not be used for long running scripts as it will over time ret= urn stale data (inMemory cache is not shared across requests/processes, so = invalidation does not happen)!

S= tash handlers configuration

General settings

To check which cache settings are available for your installation, run t= he following command in your terminal :

=20
php ezpublish/console config:dump-reference stash
=20

FileSystem=

This cache handler is using local filesystem, by default the Symfony cac= he folder, as this is per server, it does not support multi se= rver (cluster) setups!

We strongly discourage you from storing cache files on NFS= , as it defeats the purpose of the cache: speed


Available settings

path
The path where the cache is placed, default is <= code>%kernel.cache_dir%/stash, effectively ezpublish/cache/<= ;env>/stash
dirSplit
Number of times the cache key shou= ld be split up to avoid having to many files in each folder, default is 2.<= /td>
filePermissions
The permissions of the cache file,= default is 0660.
dirPermissions
The permission of the cache file d= irectories (see dirSplit), default is 0770.
memKeyLimit
Limit on how many key to path entr= ies are kept in memory during execution at a time to avoid having to recalc= ulate the path on key lookups, default 200.
keyHashFunction

Algorithm used for creating pat= hs, default md5

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 becaus= e Stash uses md5 to generate unique key that are sanitized really quickly.<= /p>

Solution is to change the hash algorithm used by Stash.=

Specifying key hash function
=20
stash:
    caches:
        default:
            handlers:
                - FileSystem
            inMemory: true
            registerDoctrineAdapter: false
            FileSystem:
                keyHashFunction: 'crc32'
=20

This configuration is only recommended for Windows users.

Note : you can also define the path where you wa= nt the cache files to be generated.

 

APC

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, us= er cache can be shared among all the workers in one pool).

Limitation

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 cont= ent 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 mo= re details please refer to the APC configuration manual.

 

Available settings

ttl The time to live of the cache in seconds, defaul= t set to 500 (8.3 minutes)
namespace A namespace to prefix cache keys w= ith to avoid key conflicts with other eZ Publish sites on same eZ Publish i= nstallation, default is null.

Memcache

This cache handler is using Memcached, a distributed caching solution, this is the only supported cache solution for multi server (clus= ter) setups!

Note

Stash supports both the php Memcache and Memcached extensio= ns. However only Memcache is officially support= ed on Redhat while Memcached is on Debian.<= /p>

If you have both extensions installed, Stash will automatically = choose Memcached.

servers

Array of Memcached servers, wit= h host/IP, port and weight

server: Host= or IP of your Memcached server
port: Port= where Memcached is listening to (defaults to 11211)
weigh= t: Weight of the server, when using several Memcached serve= rs

prefix_key<= /code> A namespace to prefix cache = keys with to avoid key conflicts with other eZ Publish sites on same eZ Pub= lish installation (default is an empty string).
Must be th= e same on all server with the same installation. See Memcached op= tion.
compression= default true. See Memcached option.
libketama_compatible= default false. <= a href=3D"http://www.php.net/manual/en/memcached.constants.php#memcached.co= nstants.opt-libketama-compatible" class=3D"external-link" rel=3D"nofollow">= See Memcached option
buffer_writes default false. <= a href=3D"http://www.php.net/manual/en/memcached.constants.php#memcached.co= nstants.opt-buffer-writes" class=3D"external-link" rel=3D"nofollow">See Mem= cached option 
binary_protocol default false. <= a href=3D"http://www.php.net/manual/en/memcached.constants.php#memcached.co= nstants.opt-binary-protocol" class=3D"external-link" rel=3D"nofollow">See M= emcached option 
no_block default false. <= a href=3D"http://www.php.net/manual/en/memcached.constants.php#memcached.co= nstants.opt-no-block" class=3D"external-link" rel=3D"nofollow">See Memcache= d option 
tcp_nodelay= default false. <= a href=3D"http://www.php.net/manual/en/memcached.constants.php#memcached.co= nstants.opt-tcp-nodelay" class=3D"external-link" rel=3D"nofollow">See Memca= ched option 
connection_timeout default 1000. See= Memcached option 
retry_timeout default 0. See Mem= cached option 
send_timeout default 0. See Memcache= d option 
recv_timeout default 0. See Memcache= d option 
poll_timeout default 1000. See Memca= ched option 
cache_lookups default false. <= a href=3D"http://www.php.net/manual/en/memcached.constants.php#memcached.co= nstants.opt-cache-lookups" class=3D"external-link" rel=3D"nofollow">See Mem= cached option 
server_failure_limit= default 0. See = Memcached option 

For in-depth information on the settings, see: http://php.net/Memcach= ed

When using Memcache handler, it's strongly recommended to also u= se inMemory cache (see example below).
This will = help reducing network traffic between your webserver and your Memcached ser= ver.

Example with M= emcache

=20
stash:
    caches:
        default:
            handlers: [ Memcache ]
            inMemory: true
            registerDoctrineAdapter: false
            Memcache:
                prefix_key: ezdemo_
                retry_timeout: 1
                servers:
                    -
                        server: 127.0.0.1
                        port: 11211
=20
------=_Part_4283_620785920.1485862254833--