chinpei215 07bf6266ab Fix that increment/decrement no longer work for XcacheEngine 10 years ago
..
Engine 07bf6266ab Fix that increment/decrement no longer work for XcacheEngine 10 years ago
Cache.php a2318a3bec Run sniffer to auto-fix default params into doc blocks. 10 years ago
CacheEngine.php 2fb0343646 remove all reference to DS contant 10 years ago
CacheRegistry.php 72f5332146 Make all doc block classes FQCN as per CS. 10 years ago
README.md 6d777f5fbf use short array syntax for docs 11 years ago
composer.json 6a7a01fe4a Declare splits as stable. 10 years ago

README.md

CakePHP Caching Library

The Cache library provides a Cache service locator for interfacing with multiple caching backends using a simple to use interface.

The caching backends supported are:

  • Files
  • APC
  • Memcached
  • Redis
  • Wincache
  • Xcache

Usage

Caching engines need to be configured with the Cache::config() method.

use Cake\Cache\Cache;

// Using a short name
Cache::config('default', [
    'className' => 'File',
    'duration' => '+1 hours',
    'path' => sys_get_tmp_dir(),
    'prefix' => 'my_app_'
]);

// Using a fully namespaced name.
Cache::config('long', [
    'className' => 'Cake\Cache\Engine\ApcEngine',
    'duration' => '+1 week',
    'prefix' => 'my_app_'
]);

// Using a constructed object.
$object = new FileEngine($config);
Cache::config('other', $object);

You can now read a write from the cache:

$data = Cache::remember('my_cache_key', function () {
	return Service::expensiveCall();
});

The code above will try to look for data stored in cache under the my_cache_key, if not found the callback will be executed and the returned data will be cached for future calls.

Documentation

Please make sure you check the official documentation