麻烦各位帮忙解读一个命令参数关于 Redis 的

使用redis 创建key 的命令 set($key, $value, $expireResolution = null, $expireTTL = null, $flag = null) 中参数都是什么意思呢? 主要是 expireResolution expireTTL flag

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
最佳答案

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. 不存在则设置
  • XX -- Only set the key if it already exist. 存在则设置

expireTTL 过期时间

5年前 评论
讨论数量: 5

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. 不存在则设置
  • XX -- Only set the key if it already exist. 存在则设置

expireTTL 过期时间

5年前 评论

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. 不存在则设置
  • XX -- Only set the key if it already exist. 存在则设置

expireTTL 过期时间

5年前 评论

过期时间,用predis跟phpredis,这个值会不一样

5年前 评论

github.com/ProgerXP/predis-doc/blo...

描述信息: set($key, $value[, $option[...]]) Set the string value of a key. Options are given inline and can be:

'EX', seconds 'PX', ms 'NX' or 'XX'

我的demo: app('redis')->set($key, $value, 'EX',100);

3年前 评论

我找到了一个 predis 的 issue:

github.com/predis/predis/issues/64...

set ($key, $value, $expireResolution = null, $expireTTL = null, $flag = null)

$expireResolution 取值为 ex | px

$expireTTL 取值为过期时间,当 $expireResolution 为 ex 时,该值的单位为秒;为 px 时单位为毫秒

$flag nx 不存在时才设定,xx 存在时设定

$redis->set($key, $value, "ex", 60, "nx"); 

相当于执行 redis 的以下命令:

SET $key $value ex 60 nx
1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!