redis tut

1. set

sadd fans ff

sadd fans bb

sadd fans cc

sadd followers cc

smembers fans

srem fans ff

spop fans

scard fans                              # return the size of fans

sismember fans cc

sinter fans followers              # return the intersection of two sets

set foo 0                                   # add a new string

sinterstore foo fans                # 将’fans’的内容copy到’foo’中,并将’foo’转为set表

sinterstore foo fans followers         # 将’fans’和‘followers’的交集的内容copy到’foo’中,并将’foo’转为set表

srandmember(foo);

2. zset

zadd students 1 90

zadd students 2 85

zadd students 3 87

zadd students 4 93

zrange students 0 -1

zrangebyscore students 3 5

zcount students 3 5

zcard students

zscore students 87

zrank students 87

zremrangebyrank students 1 3

zadd teachers 1 85

zunionstore student_teachers students teachers

 

3. list

rpush foo bar

lpush foo bar1

rpushx foo bar

llen foo

lrange foo 0 -1

lindex foo 1

lset foo 1 123

lrem foo 1 _

lpop foo

rpop foo

linsert foo before bar before_bar

 

4. hash

hset table key1 v1

hget table key1

hexists table key1

hdel table key1

hlen table

hsetx table key1 v2

hmget table

hkeys table

hvals table

hgetall table

 

5. string

set str val

setex str 10 bar

setnx str 12

getset str 56

exists str

del str

type str

setrange str 0 abc

substr str 0 2

strlen str

randomkey

rename str str1

expire foo 1

ttl foo

dbsize

 

Leave a Reply

Your email address will not be published. Required fields are marked *