3. Thinking in nosql
redis彩票项目试用总结及展望
廖旭
xliao@corp.netease.com
新浪微博 @达达尼奥
2012.5
4. Redis(REmote DIctionary Server)
is an open source, advanced key-
value store. It is often referred
to as a data structure server
since keys can contain strings,
hashes, lists, sets and sorted
sets.
The authors :
Salvatore Sanfilippo and Pieter
Noordhuis (sponsored by
VMware).
Lastest stable : 2.4
9. Data type - Strings
binary safe
max 512M
atomic counters(incr, decr)
getbit, setbit
setnx(transaction lock)
10. Data type - Lists
max 2^32 - 1 elements
lpush,rpush(o(1) time complexity)
blpop,brpop(blocking queue)
ziplist(list-max-ziplist-entries, list-max-
ziplist-value)
11. Data type - Hashes
max 2^32 - 1 field value pairs
适合存储对象(hmset, hmget)
zipmap(彩票的package、stakeOrder存储)
12. Data type - Sets
max 2^32 - 1 members
no repeated members
插入、删除、exist操作全部0(1)
取交集、并集、diff
zipset
13. Data type - Sorted Sets
和sets类似,只是每一项都有个score值
可以合并,score值加
应用场景:排名榜
15. Pipeline
Redis is a TCP server using the client-server
model and what is called a Request/Response
protocol.
频繁创建连接的 销是不可接受的
可以一次发送多个命令,不必等待之前命令的
reply