当前位置:网站首页>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
边栏推荐
- 2018 China Collegiate Programming Contest - Guilin Site J. stone game
- Challenges often faced by client project management
- Error in face detection and signature of Tencent cloud interface
- 揭秘被Arm编译器所隐藏的浮点运算
- 拨号vps会遇到什么问题?
- Some tips for using proxy IP.
- What is BGP server and what are its advantages?
- 如何对代理IP进行分类?
- Dimension C China helping farmers in rural areas warms people's hearts the third stop is jiabaoguo farm
- The leader / teacher asks to fill in the EXCEL form document. How to edit the word / Excel file on the mobile phone and fill in the Excel / word electronic document?
猜你喜欢
![[hands on learning] network depth v2.1 Sequence model](/img/51/0de4c7972a99151007a8f27f351c83.png)
[hands on learning] network depth v2.1 Sequence model

2022第六季完美童模 IPA國民賽領跑元宇宙賽道

What is an API interface?

RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimensio

Nanny level tutorial on building personal home page (II)

RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimensio

如何对代理IP进行分类?

如何选择一台好的拨号服务器?

有哪些业务会用到物理服务器?

2022 Saison 6 perfect Kid Model IPA national race Leading the Meta - Universe Track
随机推荐
批处理多个文件合成一个HEX
JDBC cannot connect to MySQL, and the error is access denied for user 'root' @ '* * *' (using password: Yes)
openstack 服务的启动
简洁开源的一款导航网站源码
What is an API interface?
NPM yarn startup error [resolved]
How to call out services in idea and display the startup class in services
Today will finally write system out. Println()
Log4j2 configuration
Leetcode46 Full Permutation
Heap overflow of kernel PWN basic tutorial
How to write the resume of Software Test Engineer so that HR can see it?
【汇编语言】从最底层的角度理解“堆栈”
使用代理IP是需要注意什么?
Leetcode39 combined sum
PID精讲
2022第六季完美童模 IPA國民賽領跑元宇宙賽道
postman里面使用 xdebug 断点调试
Is CICC fortune a company with CICC? Is it safe
What business scenarios will the BGP server be used in?