字符串常用操作
incr key
decr key
incrby key amont
decrby key amont
列表常用操作
rpush key value
lpush key value
rpop key
lpop key
lindex key offset
lrange key start end
集合
sadd key item [item…]
srem key item [item…]
sismember key item
scard key
smembers key
srandmember key [count]
spop key
hash散列
hset key-name key value
hget key-name key
hmget key-name key [key...]
hmset key-name key value [key value]
hdel key-name key [key...]
hlen key-name
hexists key-name name
hkeys key-name
hvals key-name
有序集合
zadd key-name score member [score member... ]
zrem key-name member [member…]
zcard key-name
zcount key-name min max
zrank key-name member 返回member排名
zscore key-name member
zrange key-name start stop
发布pub与订阅sub
订阅者负责订阅频道,发送者负责向频道发送二进制字符串消息。每当有消息被发送至给定频道时,频道的所有订阅者都会收到消息。
unsubscribe channel [channel…]
publish channel message
psubscribe pattern [pattern]… //订阅给定模式相匹配的所有频道
punsubscribe pattern [pattern]…
事务处理
multi 事务块开始
exec 执行所有事务块
discard 取消事务
unwatch 取消watch命令对所有key的监视
watch key [key…] 监视一个或多个key
若在事务执行前这个key被其它命令所改动 事务将被打断