当前位置:网站首页>001_redis设置存活时间
001_redis设置存活时间
2022-04-23 02:02:00 【_yummy_】
001_redis设置存活时间
1、使用expire来设置键的存活时间

- 存活时长是以秒为单位的
(1)设置键name的存活时间为20s
127.0.0.1:6379> expire name 20
(integer) 1
(2)效果展示

客户端提示:

2、在新建的键中,一般默认永久有效
127.0.0.1:6379> set name LYM
OK
127.0.0.1:6379> set age 21
OK
127.0.0.1:6379> TTL name
(integer) -1
127.0.0.1:6379> TTL age
(integer) -1
(1)其中“-1”表示永久有效的含义。

3、总结
- keys:查看符合模板的所有key,不建议在生产环境设备中使用
- del:删除 一个指定的key
- exists:判断key是否存在
- expire:给key设置一个有效期,有效期到key就会被自动删除
- ttl:查看一个key的剩余有效期
版权声明
本文为[_yummy_]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_43890515/article/details/124262204
边栏推荐
- 有哪些常见的代理ip问题?
- ThinkPHP kernel development blind box mall source code v2 0 docking easy payment / Alibaba cloud SMS / qiniu cloud storage
- PID精讲
- How to classify proxy IP?
- Quel est le fichier makefile?
- Keil MDK Chinese garbled code, two solutions, the font is no longer ugly
- Shardingsphere read write separation
- Dynamic memory management
- What problems will you encounter when dialing VPS?
- 2022 low voltage electrician examination questions and answers
猜你喜欢

Problem solving: dpkg DEB: error: package name has characters that are't lowercase alphanums or '- +‘

什么是代理IP池,如何构建?

What is a dial-up server and what is its use?

Shardingsphere sub database and sub table

Dynamic memory management

Server 2019 the available memory of the server is half of the actual memory

89 logistic回归用户画像用户响应度预测

ThinkPHP kernel development blind box mall source code v2 0 docking easy payment / Alibaba cloud SMS / qiniu cloud storage

搭建网站是用物理机还是云主机好?

Find the largest number of two-dimensional arrays
随机推荐
Leetcode40 - total number of combinations II
有哪些业务会用到物理服务器?
Server 2019 the available memory of the server is half of the actual memory
Find the largest number of two-dimensional arrays
App optimization and advanced scoreboard Part 2 [Mui + flask + mongodb]
[Leetcode每日一题]396. 旋转函数
Esp32 message queue using FreeRTOS
2022 low voltage electrician examination questions and answers
keil mdk中文乱码,两种解决方法,字体不再难看
Implementation of Base64 encoding / decoding in C language
RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimensio
CC2541的仿真器CC Debugger使用教程
EBS:PO_ EMPLOYEE_ HIERARCHIES_ ALL
Is CICC fortune a state-owned enterprise and is it safe to open an account
2018 China Collegiate Programming Contest - Guilin Site J. stone game
Dynamic memory management
What is an API interface?
简洁开源的一款导航网站源码
世界读书日 | 技术人不要错过的好书(IT前沿技术)
Micro build low code zero foundation introductory course