Your SlideShare is downloading. ×
Redis
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Redis

1,371
views

Published on

珠三角技术沙龙2011年10月分享

珠三角技术沙龙2011年10月分享

Published in: Technology, Business

0 Comments
8 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,371
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
85
Comments
0
Likes
8
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. Redis实践 翁伟
    • 2. 翁伟 / Wuvist• 新加坡海龟• 汕头招聘海盗创业中• email/gtalk/G+: wuvist@gmail.com• QQ: 124424• http://twitter.com/Wuvist
    • 3. Redis是什么?• 源K/V 数据库• V支持丰富的数据类型 • strings, hashes, lists, sets, sorted sets.• 单机• 比memcached还快
    • 4. Redis能做什么?• 最新数据列表• 排行榜• 计数器• 消息队列• 缓存
    • 5. 我拿Redis做什么?• 缓存 • Cache-Money Pattern
    • 6. Cache-Money• Twitter 源: • https://github.com/nkallen/cache-money• “A write-through and read-through caching library for ActiveRecord.”• 基于memcached• 理想情况下,数据库零读压力
    • 7. Read Through 直读• obj = Obj.FetchById(...) • 缓存不存在 • 读取数据库后写入缓存
    • 8. Active Record• 透明缓存: • 一或者多个等于条件 • ID排倒序
    • 9. 查询 => Key• select id from blogs where author_id = x and is_deleted = 0 order by id desc • blog:author_id=1:is_deleted=0• select count(*) from blogs where author_id = x and is_deleted = 0 • blog:author_id=1:is_deleted=0/c
    • 10. Write Through 直写• Obj.Save() • 写入数据库时自动写入缓存 • 下次直接读取直接命中缓存
    • 11. 实际上...• 插入新blog: • Get: blog:author_id=1:is_deleted=0 • Deserialized to Array • Append to new ID • Serialized to bytes • Set: blog:author_id=1:is_deleted=0
    • 12. 并发怎么办?• Check and Save (CAS)• 有原子操作的Append就好了∼ • Redis List
    • 13. 上Redis• Redis List • Append 无需Get/Set、无需CAS• 原生分页支持
    • 14. 更多功能• 只能ID排倒序 • Sorted Set: 任意数字化列
    • 15. Schema - less• How FriendFeed use mysql? • http://bret.appspot.com/entry/how- friendfeed-uses-mysql• 数据表: id + 单二进制列• 索引表: id + 查询条件列
    • 16. • Redis 替代索引表
    • 17. • 查询 => key• “预先”存储查询结果• 查询时间 杂度恒定 • 无“ 杂SQL”
    • 18. 还可以...• 全文搜索 • blog:fulltext:title:Redis• Type Ahead • blog:type_ahead:title:re
    • 19. • 查询 => Key• 本质上是HashTable查找• 数据库索引是B+树 • select * from blogs where author_id > 10 and is_deleted = 0
    • 20. • Sorted Set仅实现部分功能• Redis不能100%替代数据库索引
    • 21. 数据表?• 消灭MySQL,数据也放Redis• 内存限制 • 一半的可用物理内存 • 1/10问题 • MySQL解决得较好
    • 22. 分布式• Redis仅是单机方案• Sharding容易,但细节。。。
    • 23. Plurk - LightCloud• Consistent Hash Ring http://opensource.plurk.com/LightCloud/
    • 24. 我选择冬眠...• http://redis.io/presentation/Redis_Cluster.pdf
    • 25. Demo
    • 26. Q &A
    • 27. 轮子• MongoDB • 最初有误解• Redis + MySQL的轮子并不 杂,可控程 度高• FourSquare / 视觉中国也都为MongoDB 出 重的学习成本

    ×