均适用:
del key
keys * 查看所有key
exists key 检查存在
rename key new_key
expire key seconds
ttl 查看时间
persist key删除过期时间
String
set/append key value
del/get key
List
rpush key value [value1 value2]空格分开 lpush(头部)
lrange key startnum endnum 查看/选取 (左闭右闭)
lindex key index 查看(0开始)
lset key index value 修改
rpop key 头部删除 lpop 尾部删除
简记:push,range,set,pop,index,L代表List和头部
Hash
hset key k v
hget key k v
hgetall key 返回k v
hvals key
hkeys key
简记: vals keys H=hash
Set
sadd key member [m1 m2 m3]
smembers key
spop key 随机删除
srem key member [m1 m2 m3]
add rem members
Sort set (Zset)
成员是唯一的,分数是可重复的
后面分数value相同覆盖前面的。
zadd key score member [score member]
zrange key start end 左闭右闭
zrangebyscore key startscore endscore
zrem key member [m1 m2]
zremrangebyrank key start end 通过位置删除
zremrangebyscore key min max score删除