Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time

缂撳瓨

PhpBoot 浣跨敤doctrine/cache浣滀负搴曞眰缂撳瓨瀹炵幇銆俤octrine/cache 鏀寔鐨勭紦瀛樼被鍨嬫湁: APC銆丄PCu銆丮emcache銆乆cache銆丷edis銆

涓氬姟缂撳瓨

濡傛灉闇瑕佸湪涓氬姟浠g爜涓娇鐢ㄧ紦瀛, 姝ゅ浠edis涓轰緥, 婕旂ず鍩烘湰鐢ㄦ硶銆

  1. 鍦ㄤ慨鏀归厤缃枃浠 config.php, 澧炲姞浠ヤ笅浠g爜:
'redis' => \DI\object(\Doctrine\Common\Cache\RedisCache::class)
    ->method('setRedis', \DI\factory(function(){
        $redis = new \Redis();
        $redis->connect('127.0.0.1', 6379);
        return $redis;
    })),
  1. 鍦ㄦ帶鍒跺櫒涓渶瑕 redis 鐨勫湴鏂, 娉ㄥ叆 redis 瀹炰緥
/**
 * @inject redis
 * @var \Doctrine\Common\Cache\RedisCache
 */
private $redis;

绯荤粺缂撳瓨

PhpBoot 妗嗘灦涓烘彁楂樻ц兘, 浼氬皢璺敱鍙夾nnotation 鍒嗘瀽鍚庣殑鍏朵粬鍏冧俊鎭繘琛岀紦瀛樸傜敓浜х幆澧冨缓璁娇鐢 APC 鎵╁睍, 寮鍙戠幆澧冨彲浠ョ敤鏂囦欢缂撳瓨浠f浛 apc, 鏂规硶鏄湪 config.php 閲屽姞涓涓厤缃

Cache::class => \DI\object(FilesystemCache::class)
    ->constructorParameter('directory', sys_get_temp_dir())