zodyac/cache

Caching library with support for multiple cache backends

Installs: 95

Dependents: 1

Watchers: 22

Language: PHP

v0.1.2 2013-09-13 12:43 UTC

README

Caching library with a unified interface for multiple backends

Latest Stable Version Build Status

Usage

use Zodyac\Cache\Cache;
use Zodyac\Cache\Storage\ApcStorage;

$cache = new Cache(new ApcStorage());
$result = $cache->get('key');
if ($result->isMiss()) {
    $value = expensiveOperation(42);
    $cache->set('key', $value);
}

Backends

Memcached

APC

Doctrine cache bridge

Use the your Zodyac\Cache\Cache instance as a Doctrine Cache with Zodyac\Cache\DoctrineCache. This is useful when you want to use Zodyac Cache for metadata, query or result caching in Doctrine ORM.

use Zodyac\Cache\Cache;
use Zodyac\Cache\DoctrineCache;
use Zodyac\Cache\Storage\ApcStorage;

$cache = new Cache(new ApcStorage());
$doctrineCache = new DoctrineCache($cache);
$value = $doctrineCache->doFetch('key');

Credits