# Redis command
- 获取所有key
# 获取所有key
keys *
# 根据开头获取key列表
keys sth*
1
2
3
4
2
3
4
- 获取单个key(没有返回 nil)
get keyname
1
- 给单个key赋值
set keyname keyvalue
1
- 设置过期时间
# 过期时间为30秒
EXPIRE keyname 30
1
2
2
- 查看剩余生存时间
TTL keyname
1
- 删除某个key(删除正确 返回1)
del key
1
- 将数据+1
incr key
1
- 清空整个缓存(当前db)
flushdb
1
- 登陆
auth password
1
- 创建Hash
hmset lilei name "LiLei" age 25 title "Senior"
1
- 获取hash
hget lilei age
1
- 设置hash
hset lilei age 26
1
- List
lpush mylist 1231 lpush mylist 21313
1
- 获取List
lrange mylist 0 10
1
- Set
sadd myset 111 sadd myset 222
1
- 获取set
smembers myset
1
- Sorted Set
zadd myset 1 abd zadd myset 2 adb zadd myset 2 abc
1
- 获取Sorted Set
zrangebyscore myset 0 10
1
- scan cursor match [pattern] [count]
scan 0 match zzx* count 10
1
- setnx 操作 设置锁
- set key value [ex seconds] [px milliseconds] [nx|xx]
SET locktarget ex 10 nx
1
2
2