zodyac/cache

该包已被废弃且不再维护。没有建议的替代包。

支持多个缓存后端的缓存库

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

This package is not auto-updated.

Last update: 2021-04-11 21:57:39 UTC


README

具有统一接口的多后端缓存库

Latest Stable Version Build Status

用法

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);
}

后端

Memcached

APC

Doctrine 缓存桥接器

使用 Zodyac\Cache\Cache 实例作为 Doctrine Cache,通过 Zodyac\Cache\DoctrineCache。这在您想使用 Zodyac Cache 进行 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');

鸣谢