在Redis中查找未过期的密钥 [英] Finding non-expiring keys in Redis

查看:15
本文介绍了在Redis中查找未过期的密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的设置中,info 命令显示了以下内容:

In my setup, the info command shows me the following:

[keys] => 1128
[expires] => 1125

我想找到没有到期日期的那 3 个密钥.我已经检查了文档无济于事.有什么想法吗?

I'd like to find those 3 keys without an expiration date. I've already checked the docs to no avail. Any ideas?

推荐答案

修改自一个我现在找不到的网站.

Modified from a site that I can't find now.

redis-cli keys  "*" | while read LINE ; do TTL=`redis-cli ttl "$LINE"`; if [ $TTL -eq  -1 ]; then echo "$LINE"; fi; done;

注意,这是一个阻塞调用.

edit: Note, this is a blocking call.

这篇关于在Redis中查找未过期的密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆