Yii::$service->session->get()
执行的是 https://github.com/fecshop/yii2_fecshop/blob/master/services/session/SessionRedis.php
最终的存储并不是放到php session里面
public function set($key, $val, $timeout)
{
$key = $this->getSessionKey($key);
$val = $val . $this->valSeparator . time();
return (bool) Yii::$app->redis->executeCommand('SET', [$key, $val, 'EX', $timeout]);
}
public function get($originKey, $reflush)
{
$key = $this->getSessionKey($originKey);
$data = Yii::$app->redis->executeCommand('GET', [$key]);
$arr = explode($this->valSeparator, $data);
if (count($arr) < 2) {
return '';
}
$val = $arr[0];
$timeout = $arr[1];
if (Yii::$service->session->isUpdateTimeOut($timeout) && $val) {
$this->set($originKey, $val, $timeout);
}
return $val === false || $val === null ? '' : $val;
}
public function remove($key)
{
$key = $this->getSessionKey($key);
Yii::$app->redis->executeCommand('DEL', [$key]);
// @see https://github.com/yiisoft/yii2-redis/issues/82
return true;
}
执行的是 Yii::$app->redis->executeCommand