Redis(0X01)


Try Redis

1
2
3
4
5
6
7
8
SET server:name 'fido'
GET server:name
DEL server:name
SET index 10
INCR index [atomic operation]
SETNX count 10
EXPIRE count 60
TTL count [time to live,-1:never expire -2:var undefined]
1
2
3
4
5
6
7
RPUSH friends 'Alice'
RPUSH friends 'Bob'
LPUSH friends 'Sam'
LRANGE friends 0 1 [0 -1 is tell to the end of the list]
LPOP friends 'Sam'
RPOP friends 'Bob'
LLEN friends [list len]
1
2
3
4
5
6
7
8
SADD superpowers 'flight'
SADD superpowers 'x-ray vision'
SADD superpowers 'reflexes'
SREM superpowers 'reflexes'
SISMEMBER superpowers 'reflexes'
SMEMBERS superpowers
SADD birdpowers 'pecking'
SUNION superpowers birdpowers
1
2
3
4
5
ZADD hackers 1912 'Alan Turing' [SortedSets is Z]
ZADD hackers 1906 'Grace Hopper'
ZADD hackers 1940 'Alan Kay'
ZRANGE 0 1
...
1
2
3
4
5
6
HSET user:10 name 'Alan Kay' year '1940' [hash]
HGETALL user:10
HGET user:10 name
HSET user:11 visits 10
HINCRBY user:11 visits 1 [visits = 10+1]
...

#Summary:

  1. L~list S~set Z~SortedSets H~hash