AtkCache
Appearance
When you want to cache some data, you can use atkCache for it. At this moment atkCache has support for the following:
- APC (Alternative PHP Cache)
- eAccelerator
- Memcache to store data in RAM on the localhost or on another server
- Xcache
- File (which stores data in the file system)
- Var (a variable-based cache that lasts only for the duration of a page load)
- Zend Platform (3 versions, output cache, disk cache and shared memory cache, the last two can only be used with version 3.6 and higher of Zend Platform).
Configuration
By the default the lifetime for a cached value will be 1 hour for every method. This can be altered by adding the followin config to you config.inc.php
$config_cache[<method>]['lifetime']=300;
Some cache method's also require some other settings.
File cache:
// Directory where the cache will be written
$config_cache['file']['path']=atkconfig('atktempdir')."cache/";
// Context var for fopen
$config_cache['file']['context']=array();
Memcache:
// Servername
$config_cache['memcache']['host']='localhost';
// Port
$config_cache['memcache']['port']=11211;
// Connection timeout
$config_cache['memcache']['timeout']=1;
xCache:
// Admin Username (needed for deleteall method)
$config_cache['xcache']['user']='';
// Password
$config_cache['xcache']['passwd']='';
There are 2 ways to set a default cache. Option 1 is by giving an array with available methods. atkCache will choose the first available cache method (fallback). Option 2 is just setting only 1 cache method. Available cache methods are:
- var (default)
- file
- apc
- eaccelerator
- xcache
- memcache
- zp_output (Zend Platform 3.6 and lower, it's deprecated in the 3.6)
- zp_shm (Zend Platform 3.6 and higher)
- zp_disk (Zend Platform 3.6 and higher)
// Let atkCache choose the first available cache method
$config_cache_method = array('zp_shm','file');
// Or just set one cache method that should be used
$config_cache_method = 'zp_disk';
</php
When you application is hosted on a shared hosting which provides one of the cache methods, you can set a namespace so your keys won't override any other existing keys.
<syntaxhighlight lang="php">
$config_cache_namespace = 'default';