如圖,redis版本是phpstudy下載的
在依賴是 "illuminate/redis": "^7.26"的情況下
文檔是有問題的,第三個(gè)參數(shù)不是 timeout
$userInfo = Redis::set('test','mytest','EX',10);這樣才對(duì),這樣設(shè)置過期時(shí)間是10秒
下面是對(duì)的
public function set($key, $value, $expireResolution = null, $expireTTL = null, $flag = null)
第一個(gè)參數(shù) 和第二個(gè)參數(shù)不用講
expireResolution 是過期策略,比如
EX seconds -- Set the specified expire time, in seconds. 秒
PX milliseconds -- Set the specified expire time, in milliseconds. 毫秒
NX -- Only set the key if it does not already exist. 不存在則設(shè)置
XX -- Only set the key if it already exist. 存在則設(shè)置
第四個(gè)參數(shù)是
expireTTL 過期時(shí)間