This document summarizes the features, architecture, administration, capacity forecasting, replication, persistence, and table design concepts of Redis. Key points include Redis' data structures of strings, lists, hashes and sets; its single-threaded model with auxiliary threads; persistence via snapshots to disk and AOF logging; master-slave replication topology without resume of broken transfers; and example user login data modeled as keys and indexes in Redis.
3. Feature
redis memcached
data structure string|list|hash|set|zset string
thread model third(main thread, two many
auxiliary thread)
demultiplexer ae.c libevent(3rd library)
persistence yes no
replication yes no
design weak no
4. String
Set hello world
Set hello 1234567
Set hello 1234
5. List
Lpush list aaaa bbb ccc
Double link list, so can lpush,rpush,lpop,rpop
6. Zipmap
Hset test hello world
Hset test aliyun dba
Zipmap defect:Zmlen one bytes, only 253 subkey
15. Table desgin login user
Design a login user system
Heap table
userid login_times last_login_time
1 5 2011-1-1
2 1 2011-1-2
3 2 2011-1-3
Last login man? Create index on last_login_time
Max login man? Create index on login_times
Index, explan plan, compute statistics is suck!!!
16. Login user
data
Set userid:1:login_times 5
Set userid:2:login_times 1
Set userid:3:login_times 2
Set userid:1:last_login 2011-1-1
Set userid:2:last_login 2011-1-2
Set userid:3:last_login 2011-1-3
Last login
lpush user_last_login 1
lpush user_last_login 2
lpush user_last_login 3
ltrim user_last_login 0 1
17. Login user
Max login man
zadd user:login_times 5 1
zadd user:login_times 1 2
zadd user:login_times 2 3
zcard user:login_times
zrangebyscore user:login_times 3 +inf withscores
Column store data?