Skip to content
renakeji edited this page Oct 24, 2016 · 8 revisions

缓存

SDK 使用 doctrine/cache 作为缓存组件,该组件包含多种缓存驱动,开发者可以自由选择,详情请参考官方文档:

http://doctrine-orm.readthedocs.org/projects/doctrine-orm/en/latest/reference/caching.html

Filesystem

$cacheDriver = new \Doctrine\Common\Cache\FilesystemCache('./cacheDir');

APC

$cacheDriver = new \Doctrine\Common\Cache\ApcCache();

Memcache

$memcache = new Memcache();
$memcache->connect('127.0.0.1', 11211);

$cacheDriver = new \Doctrine\Common\Cache\MemcacheCache();
$cacheDriver->setMemcache($memcache);

Mamcached

$memcached = new Memcached();
$memcached->addServer('127.0.0.1', 11211);

$cacheDriver = new \Doctrine\Common\Cache\MemcachedCache();
$cacheDriver->setMemcached($memcached);

Xcache

$cacheDriver = new \Doctrine\Common\Cache\XcacheCache();

Redis

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);

$cacheDriver = new \Doctrine\Common\Cache\RedisCache();
$cacheDriver->setRedis($redis);