Popularity
2.6
Stable
Activity
0.0
Stable
51
30
10

Description

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:

Code Quality Rank: L4
Programming language: PHP
License: GNU General Public License v3.0 or later
Tags: Caching     Cache     Cakephp    
Latest version: v4.1.0-RC2

Cake Cache alternatives and similar libraries

Based on the "Caching" category.
Alternatively, view Cake Cache alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Cake Cache or a related project?

Add another 'Caching' Library

README

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\ApcuEngine::class,
    'duration' => '+1 week',
    'prefix' => 'my_app_'
]);

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

You can now read and 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