02[把握]redis詳細コマンド
3114 ワード
1、共通コマンド
2,stringタイプ関連コマンド
構文set key value
3,list【集合配列】
構文lpush key values lpush mylist a b c左挿入
4,hash
構文:hset key value-key value-value
5,set
6,zset
keys * key
select 0
move myString 1 key , ,
flushdb
randomkey
type key
del key1 key
exists key key
expire key 10
pexpire key 1000
persist key
ttl key ,-1 ,-2
2,stringタイプ関連コマンド
構文set key value
set name cxx
get name
getrange name 0 -1 0 -1 0 -2 ==n-1
getset name new_cxx ,
mset key1 key2
mget key1 key2
setnx key value (not exists)
setrange key index value index value
incr age
incrby age 10
decr age
decrby age 10
incrbyfloat
append
strlen
object encoding key key string
int 64
embstr 44 Redis3.x 39 ,
raw 44
3,list【集合配列】
構文lpush key values lpush mylist a b c左挿入
rpush mylist x y z
lrange mylist 0 -1 0 -1 0 1
lpop mylist
rpop mylist
llen mylist
lrem mylist count value
|-COUNT :
|--count > 0 : , VALUE , COUNT 。
|--count < 0 : , VALUE , COUNT 。
|--count = 0 : VALUE 。
lindex mylist 2
lset mylist 2 n
ltrim mylist 0 4
|-- (trim), , , 。
0 , 1 , 。
, -1 , -2 , 。
linsert mylist before a
linsert mylist after a
|-- 。 , 。
, , 。 key , 。
rpoplpush list list2
|-- , 。
4,hash
構文:hset key value-key value-value
hset myhash name cxx
|-- 。
|-- , HSET 。
|-- , 。
hget myhash name
hmset myhash name cxx age 25 note "i am notes"
hmget myhash name age note
hgetall myhash
hexists myhash name
hsetnx myhash score 100 ,
hincrby myhash id 1
hdel myhash name
hkeys myhash key
hvals myhash value
hlen myhash
5,set
sadd myset redis
smembers myset
srem myset set1
sismember myset set1
scard key_name
sdiff key1 key2 …… | sinter | sunion : : | |
srandmember key count
spop
6,zset
zadd zset 1 one
zadd zset 2 two
zadd zset 3 three
zincrby zset 1 one
zscore zset two
zrange zset 0 -1 withscores
zrangebyscore zset 10 25 withscores
zrangebyscore zset 10 25 withscores limit 1 2
Zrevrangebyscore zset 10 25 withscores
zcard zset
Zcount zset
Zrem zset one two
Zremrangebyrank zset 0 1
Zremrangebyscore zset 0 1
Zrank zset 0 -1 0
Zrevrank zset 0 -1 0
Zinterstore
zunionstore rank:last_week 7 rank:20150323 rank:20150324 rank:20150325 weights 1 1 1 1 1 1 1