redis命令

数据类型:

String

get, set, incr, decr

Hdash

hset girl age 18
hget gial age
hkeys girl
hvals girl
hgetall girl

List

lpush list1 a
lpush list1 b c d
lrange list1 0 -1 (从左边开始看) (-1不限制长度)
rpush (从右边加)
lpop (从左边pop)
rpop

Set

sadd set1 a a b b c d
smembers set1 -> a b c d
srem set1 a
sdiff set1 set2 (集合相减)
sinter set1 set2 (相交)
sunion set1 set2 (并集)

sortSet

zadd zset1 2 a 3 b 3 d 4 c
zrange zset1 0 -1
zrem zset1 a
zrevrange zset1 0 -1 withscores

其他

expire key1 100 (设置key的过期时间)
ttl key1 (查看key的有效期)
persist key1 (清除key的有效期,使key持久化)

你可能感兴趣的:(redis命令)