Zend_Cache Backends
There are two kinds of backends: standard ones and extended ones. Of course, extended
backends offer more features.
Zend_Cache_Backend_File
This (extended) backends stores cache records into files (in a choosen directory).
Available options are :
File Backend Options
Option |
Data Type |
Default Value |
Description |
cache_dir |
String |
'/tmp/' |
Directory where to store cache files
|
file_locking |
Boolean |
TRUE |
Enable or disable file_locking : Can avoid cache corruption under
bad circumstances but it doesn't help on multithread webservers
or on NFS filesystems...
|
read_control |
Boolean |
TRUE |
Enable / disable read control : if enabled, a control key is
embedded in the cache file and this key is compared with the
one calculated after the reading.
|
read_control_type |
String |
'crc32' |
Type of read control (only if read control is enabled). Available values
are : 'md5' (best but slowest), 'crc32' (lightly less safe but faster,
better choice), 'adler32' (new choice, faster than crc32),
'strlen' for a length only test (fastest).
|
hashed_directory_level |
Integer |
0 |
Hashed directory structure level : 0 means "no hashed directory
structure", 1 means "one level of directory", 2 means "two levels"...
This option can speed up the cache only when you have many thousands of
cache files. Only specific benchs can help you to choose the perfect
value for you. Maybe, 1 or 2 is a good start.
|
hashed_directory_umask |
Integer |
0700 |
Umask for the hashed directory structure
|
file_name_prefix |
String |
'zend_cache' |
prefix for cache files ; be really careful with this option because
a too generic value in a system cache dir
(like /tmp) can cause disasters when cleaning
the cache
|
cache_file_umask |
Integer |
0700 |
umask for cache files
|
metatadatas_array_max_size |
Integer |
100 |
internal max size for the metadatas array (don't change this value
unless you know what you are doing)
|
Zend_Cache_Backend_Sqlite
This (extended) backends stores cache records into a SQLite database.
Available options are :
Sqlite Backend Options
Option |
Data Type |
Default Value |
Description |
cache_db_complete_path (mandatory) |
String |
NULL |
The complete path (filename included) of the SQLite database
|
automatic_vacuum_factor |
Integer |
10 |
Disable / Tune the automatic vacuum process. The automatic vacuum
process defragment the database file (and make it smaller) when a
clean() or delete()
is called: 0 means no automatic vacuum ; 1 means systematic vacuum
(when delete() or
clean() methods are called) ; x (integer) >
1 => automatic vacuum randomly 1 times on x
clean() or
delete().
|
Zend_Cache_Backend_Memcached
This (extended) backends stores cache records into a memcached server. » memcached is a high-performance,
distributed memory object caching system. To use this backend, you need a memcached
daemon and » the memcache
PECL extension.
Be careful : with this backend, "tags" are not supported for the moment as
the "doNotTestCacheValidity=true" argument.
Available options are :
Memcached Backend Options
Option |
Data Type |
Default Value |
Description |
servers |
Array |
array(array('host' => 'localhost', 'port' => 11211,
'persistent' => true, 'weight' => 1, 'timeout' => 5,
'retry_interval' => 15, 'status' => true,
'failure_callback' => '' ))
|
An array of memcached servers ; each memcached server is described by
an associative array : 'host' => (string) : the name of the memcached
server, 'port' => (int) : the port of the memcached server,
'persistent' => (bool) : use or not persistent connections to this
memcached server 'weight' => (int) :the weight of the memcached
server, 'timeout' => (int) :the time out of the memcached server,
'retry_interval' => (int) :the retry interval of the memcached server,
'status' => (bool) :the status of the memcached server,
'failure_callback' => (callback) : the failure_callback of the
memcached server
|
compression |
Boolean |
FALSE |
TRUE if you want to use on-the-fly compression
|
compatibility |
Boolean |
FALSE |
TRUE if you want to use this compatibility mode
with old memcache servers or extensions
|
Zend_Cache_Backend_Apc
This (extended) backends stores cache records in shared memory through
the » APC (Alternative
PHP Cache) extension (which is of course need for using this
backend).
Be careful : with this backend, "tags" are not supported for the moment as
the "doNotTestCacheValidity=true" argument.
There is no option for this backend.
Zend_Cache_Backend_Xcache
This backends stores cache records in shared memory through
the » XCache extension
(which is of course need for using this backend).
Be careful : with this backend, "tags" are not supported for the moment as
the "doNotTestCacheValidity=true" argument.
Available options are :
Xcache Backend Options
Option |
Data Type |
Default Value |
Description |
user |
String |
NULL |
xcache.admin.user, necessary for the
clean() method
|
password |
String |
NULL |
xcache.admin.pass (in clear form, not
MD5), necessary for the
clean() method
|
Zend_Cache_Backend_TwoLevels
This (extend) backend is an hybrid one. It stores cache records in two other backends :
a fast one (but limited) like Apc, Memcache... and a "slow" one like File, Sqlite...
This backend will use the priority parameter (given at the frontend level when storing a
record) and the remaining space in the fast backend to optimize the usage of these two
backends.
Specify this backend using a word separator -- '-', '.', ' ', or '_'
-- between the words 'Two' and 'Levels' when using the
Zend_Cache::factory() method:
$cache = Zend_Cache::factory('Core', 'Two Levels');
Available options are :
TwoLevels Backend Options
Option |
Data Type |
Default Value |
Description |
slow_backend |
String |
File |
the "slow" backend name
|
fast_backend |
String |
Apc |
the "fast" backend name
|
slow_backend_options |
Array |
array() |
the "slow" backend options
|
fast_backend_options |
Array |
array() |
the "fast" backend options
|
slow_backend_custom_naming |
Boolean |
FALSE |
if TRUE, the slow_backend argument is used as a
complete class name; if FALSE,
the frontend argument is used as the end of
"Zend_Cache_Backend_[...]" class name
|
fast_backend_custom_naming |
Boolean |
FALSE |
if TRUE, the fast_backend argument is used as a
complete class name; if FALSE,
the frontend argument is used as the end of
"Zend_Cache_Backend_[...]" class name
|
slow_backend_autoload |
Boolean |
FALSE |
if TRUE, there will no require_once for the
slow backend (useful only for custom backends)
|
fast_backend_autoload |
Boolean |
FALSE |
if TRUE, there will no require_once for the fast
backend (useful only for custom backends)
|
auto_refresh_fast_cache |
Boolean |
TRUE |
if TRUE, auto refresh the fast cache when a
cache record is hit
|
stats_update_factor |
Integer |
10 |
disable / tune the computation of the fast backend filling percentage
(when saving a record into cache, computation of the fast backend
filling percentage randomly 1 times on x cache writes)
|
Zend_Cache_Backend_ZendServer_Disk and Zend_Cache_Backend_ZendServer_ShMem
These backends store cache records using » Zend
Server caching functionality.
Be careful: with these backends, "tags" are not supported for the moment as the
"doNotTestCacheValidity=true" argument.
These backend work only withing Zend Server environment for pages requested through
HTTP or HTTPS and don't work for command line
script execution
Specify this backend using parameter customBackendNaming as
TRUE when using the Zend_Cache::factory()
method:
$cache = Zend_Cache::factory('Core', 'Zend_Cache_Backend_ZendServer_Disk',
$frontendOptions, $backendOptions, false, true);
There is no option for this backend.
|
|