# 02-Redis 常见FAQ

# 1.远程服务上执行命令

$ redis-cli -h host -p port -a password
1

** -h 服务器地址 -p 端口号 -a 密码**

# 2.查看过期时间和设置过期时间

# 不存在的 key

redis> FLUSHDB
OK

redis> TTL key
(integer) -2


# key 存在,但没有设置剩余生存时间

redis> SET key value
OK

redis> TTL key
(integer) -1


# 有剩余生存时间的 key

redis> EXPIRE key 10086
(integer) 1

redis> TTL key
(integer) 10084
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

Redis TTL 命令 (opens new window)

Last Updated: 5/30/2023, 10:49:10 AM
Apache License 2.0 | Copyright © 2022 by xueliang.wu 苏ICP备15016087号