平时经常需要使用到redis
在实际应用中,我们经常需要设置当天就失效的key
比如当天留言的次数不能超过3次,如果超过3次,则今天不能再继续留言
<?php
$msg_times = 'msg:times:'.date("Ymd");
$this->redis->incr($msg_times);
if($this->redis->get($msg_times) == 3) {
$this->redis->expire($msg_times, strtotime(date('Y-m-d').'23:59:59') - time());
}
?>
如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术
转载请注明:php中设置redis当天失效的key 出自老鄢博客 | 欢迎分享