我的YII版本:1.1.12 ...从头开始,我升级到版本1.1.13,但仍然无法正常工作。Yii时间缓存不起作用?
我尝试这样做:
Yii::app()->cache->set('someKey', $auctions);
$data = Yii::app()->cache->get('someKey');
print_r($data);
而且我看到我存储的数据!但是,如果我试试这个:
Yii::app()->cache->set('someKey', $auctions, 10);
$data = Yii::app()->cache->get('someKey');
print_r($data);
我什么都看不见?为什么YII会忽略我的时间间隔?我错过了什么?
**编辑**
我的缓存中的配置定义为:
'cache'=>array(
'class'=>'system.caching.CMemCache',
'useMemcached'=>false,
'servers'=>array(
array('host'=>'127.0.0.1', 'port'=> 11211, 'weight'=>60),
//array('host'=>'server2', 'port'=>11211, 'weight'=>40),
),
),
我知道Memcache的工作,因为我已经与Yii框架之外这个例子中测试了它:
$memcache = new Memcache;
$memcache->connect("localhost",11211);
$tmp_object = new stdClass;
$tmp_object->str_attr = "test";
$memcache->set("mysupertest",$tmp_object,false,5);
var_dump($memcache->get("mysupertest"));
这个工程和项目缓存5秒......
在你的conf文件并û定义什么类型的高速缓存? – darkheir 2013-02-19 10:11:41
我已更新我的问题,并提供更多信息。 – coderama 2013-02-19 10:23:42
尝试看看'Yii :: app() - > cache-> set('someKey',$ auctions,10);'return'true'或不是 – darkheir 2013-02-19 10:49:15