redis->getClient()->get($key); } catch (Exception $e) { throw new CException(Yii::t('model', $e->getMessage())); } } /** * set * * @param string $data * @return void * @param $time 在redis里的有效时间 */ public static function set($key, $data, $time = 86400) { try { $return = Yii::app()->redis->getClient()->set($key, $data); if($time != null){ return Yii::app()->redis->getClient()->expire($key, $time); }else{ return $return; } } catch (Exception $e) { throw new CException(Yii::t('model', $e->getMessage())); } } public static function remove($key) { try { Yii::app()->redis->getClient()->del($key); return true; } catch (Exception $e) { throw new CException(Yii::t('model', $e->getMessage())); } } }