Redis 数据库 TTL [英] Redis Database TTL

查看:55
本文介绍了Redis 数据库 TTL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何要创建一个 Redis 数据库,其中密钥必须在一定时间后过期?我知道我可以使用 EXPIRE 命令使单个密钥过期,但由于无论如何我都会在一定时间后使每个密钥过期,因此在 Redis 配置文件中指定此行为会很好.

Is there anyway to create a Redis database where keys HAVE TO expire after a certain time? I know I can expire an individual key using the EXPIRE command but since I am expiring every key after a certain time anyways, it would be nice to have this behavior specified in the Redis config file.

推荐答案

不,Redis(直到并包括 v3.2)不提供自动设置新创建键的 TTL 的方法.您必须为您创建的每个密钥显式设置它.

No, Redis (up to and including v3.2) does not provide the means for automatically setting the TTL of newly-created keys. You have to set it explicitly for each key you create.

这篇关于Redis 数据库 TTL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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