1.set server:name "fido"
get server:name
2.set connections 10
get connections
incr connections
incr connections
del connections
get connections
incr connections
get connections
3.set resource:lock "redis demo"
expire resource:lock 120
ttl resource:lock ttl -1 never expire,-2 doesn't exist
4.list
rpush friends "Alice"
rpush friends "Bob"
lpush friends "Sum"
lrange friends 0 1
lrange firends 1 -1
llen friends
lpop friends
rpop friends
5.set
sadd superpower "flight"
sadd superpower "x-ray vision"
sadd superpower "reflexes"
srem superpower "x-ray vision"
sismember superpower "flight"
smembers superpower
sadd birdpower "flight"
sadd birdpower "pecking"
sunion birdpower superpower
6.sorted set
zadd hackers 1960 "Alan Kay"
zadd hackers 1906 "Grace Hopper"
zadd hackers 1953 "Richard Stallman"
zadd hackers 1965 "Ybkihiro Matsumoto"
zadd hackers 1916 "Claude Shannon"
zadd hackers 1969 "Linus Torvalds"
zadd hackers 1957 "Sophie Wilson"
zadd hackers 1912 "Alan Turing"
zrange hackers 2 4
7.Hashes
hset user:1000 name "John Smith"
hset user:1000 email "john smith@example.com"
hset user:1000 password "s3cret"
hgetall user:1000
HMSET user:1001 name "Mary Jones" password "hidden" email "mjones@example.com"
hget user:1001 name
hset user:1000 visits 10
hincrby user:1000 visits 1
hincrby user:1000 visits 10
hdel user:1000 visits
hincrby user:1000 visits 1