如何在Yii 1中更新redis缓存

时间:2017-02-07 09:15:34

标签: php yii redis-cache

我正在尝试重新设置缓存,但每次执行此操作时,到期时间都会保持活动状态。如何在不影响到期时间的情况下更新redis缓存。

$cache = Yii::app()->cache;
if($cache->get($md5)){
    $md5Values = $cache->get($md5);
    $md5Values['repetition'] +=1;
    $md5Values['priority'] = 2;var_dump($cache->get($md5));
    $cache->set($md5,$md5Values);
    if ($md5Values['repetition'] > 10 && $md5Values['repetition'] <= 1000){

        $md5Values['priority'] = 1;
        $cache->set($md5,$md5Values);
        var_dump($cache->get($md5));
        return  array('priority'=>1);
    } elseif ($md5Values['repetition'] > 1000){
        $md5Values['priority'] = 0;
        $cache->set($md5,$md5Values);
        return  array('priority'=>0);
    }
    return false;
}else{
    $cacheArray=array();
    $cacheArray['repetition'] = 1;
    $cacheArray['priority'] = 2;
    $cache->set($md5,$cacheArray,30);
    return false;
} 

0 个答案:

没有答案