问答平台(4),Redis入门
Redis 数据类型
1 |
|
Redis 存储
1 |
|
Redis 应用场景
1 |
|
Redis 命令
- 启动
1
redis-cli
- 字符
1
2
3
4
5
6select 1(0-15)
flushdb
set test:count 1
get test:count
incr test:count
decr test:count - 哈希
1
2
3
4hset test:user id 1
hset test:user username zhangsan
hget test:user id
hget test:user username - 列表
1
2
3
4
5
6
7
8lpush test:ids 101 102 103
llen test:ids
lindex test:ids 0
lindex test:ids 2
lrange test:ids 0 2
rpop test:ids
lpop test:ids
lrange test:ids 0 2 - 集合
1
2
3
4sadd test:teachers aaa bbb ccc ddd eee
scard test:teachers
spop test:teachers(从集合中随机弹出一个元素)
smembers test:teachers - 有序集合
1
2
3
4
5zadd test:students 10 aaa 20 bbb 30 ccc 40 ddd 50 eee
zcard test:students
zscore test:students ccc
zrank test:students ccc
zrange test:students 0 2 - 全局
1
2
3
4
5
6keys *
keys test*
type test:user
exists test:user
del test:user
expire test:students 10(单位:s)
参考资料
问答平台(4),Redis入门
https://lcf163.github.io/2020/05/22/问答平台(4),Redis入门/