2013-09-26 118 views

回答

0

前端配置文件:

'cache' => array(
    'class'  => 'system.caching.' . (!MW_DEBUG ? 'CFileCache' : 'CDummyCache'), 
    'keyPrefix' => md5('frontend.' . MW_VERSION . Yii::getPathOfAlias('frontend')), 
), 

控制台配置文件:

'cache' => array(
    'class'  => 'system.caching.' . (!MW_DEBUG ? 'CFileCache' : 'CDummyCache'), 
    'keyPrefix' => md5('console.' . MW_VERSION . Yii::getPathOfAlias('backend')), 
), 

reference answer

3

我得到同样的问题,这是通过保持相同的设置为后端和前端这两个应用解决。

'cache'=> array(
    'class' => 'CRedisCache', 
    'hostname' => 'localhost', 
    'port' => 6379, 
    'database' => 0, 
    'hashKey' => false, 
    'keyPrefix' => '', 
); 

集keyPrefix空和hashKey为false,

如果您使用keyPrefix和hashKey CRedisCache默认设置会造成从set命令 如提供相同的值不同的密钥。

Yii::app()->cache->set('foo', 'bar'); frontend server 
will create key in redis something like "0327f5f7378e9056c775ab69aa206322" 

    Yii::app()->cache->set('foo', 'bar'); backend server 
ll create key in redis something like "d2c81df2db2285435c1975b5cb5c5b66"  

CRedisCache通过对每个请求的服务器使用hashKey和keyPrefix的组合来创建唯一密钥。

+1

FWIW,你不需要真正将hashKey设置为false(实际上你不应该)。只要确保keyPrefix在控制台和Web应用程序上都相同就足够了。 – pkid169

相关问题