a.String
查询值:get key
设置值:set key [val]
批量查询:mget key key
批量设置:mset key [val] key [val]
b.Hash
查询值:hget key [field]
设置值:hset key [field] [val]
批量查询:hmget key [field] [field]
批量设置:hmset key [field] [val] [field] [val]
c.List
查询值:lrange key [start] [stop]
设置值:lset key [index] [val]
删除值:lrem key count val,返回被删除的个数
count>0,从左边开始删除前count个值为val的元素
count<0,从右边开始删除前|count|个值为val的元素
count=0,删除所有值为value的元素
d.Set
查询值:smembers key 返回全部元素
设置值:sadd key [val...]
删除值:srem key [val...]
e.Zset
添加值:zadd key [NX|XX] [CH] [INCR] score member [score member ...]
获取元素分数:zscore key member
元素小到大:zrange key start top [WITHSCORES]
元素大到小:zrevrange key start [WITHSCORES]
增加分数:zincrby key increment member
f.其他常用命令
KEYS * 获得当前数据库的所有键
EXISTS key [key ...] 判断键是否存在,返回个数,如果key有一样的也是叠加数
DEL key [key ...] 删除键,返回删除的个数
TYPE key 获取key的值的数据类型(string,hash,list,set,zset)