Another Introduce to Redis

  • Published on
    07-Jul-2015

  • View
    670

  • Download
    5

Embed Size (px)

Transcript

<ul><li> 1. Another Introduce to Redishttp://jiaqing.me 2012-05-21</li></ul> <p> 2. RedisRedisRedis 2 3. Part 1Redis 3 4. :Redis is an open source, advanced key-value store. It is often referred to asa data structure server since keys cancontain strings, hashes, lists, sets and sorted sets.4 5. :Redis is an open source, advanced key-value store. It is often referred to asa data structure server since keys cancontain strings, hashes, lists, sets and sorted sets.:Key-value 5 6. Redis vs Memcached 6 7. Redis vs Memcached Redis Redis Redis Redis Redis Redissharding7 8. key: String : my name Error mynamen Error : object-type:id:field user:1000:password8 9. value: String: , 1G List String Set String SortSet Set score HashStringk-v 9 10. eg.listLPUSH mylist a # now the list is aLPUSH mylist b # now the list is b, aRPUSH mylist c # now the list is b, a, c 10 11. eg.hash http://try.redis-db.com/ http://redis.io/commands http://redis.readthedocs.org/en/latest/ 11 12. redis&gt; multiOK multi redis&gt; incr a exec QUEUED discardredis&gt; incr bQUEUEDredis&gt; exec1. (integer) 12. (integer) 1 12 13. Snapshotting: Nsave 900 1 #9001keysave 300 10 #30010keysave 60 10000 #... 13 14. AOFappend-only file: appendfsync always #appendfsync everysec #appendfsync no #OS, 14 15. MasterSlave MasterSlave 15 16. valueswap 16 17. RedisCC++C#JavaLuaNode.jsPerlGoRubyPHP http://redis.io/clients 17 18. Part 2Redis 18 19. 19 20. IDSET global:newUserId 0 INCR global:nextUserId=&gt; 1000SET uid:1000:username asukaSET uid:1000:password *****SET uid:1000:url /asukaSET uid:1000:xxx xxxxxxxxx20 21. / # SADD uid:1000:following 1001 SADD uid:1000:following 1002 SADD uid:1000:following 1003 # SADD uid:1000:followers 0001SADD uid:1000:followers 0002SADD uid:1000:followers 0003#SMEMBERS uid:1000:following=&gt;1002,1003,1001#SCARD uid:1000:followers=&gt;3#SINTER uid:1000:following uid:1001:following 21 22. # SET postid:900001 RPUSH uid:1000:posts 900001# RPUSH uid:1001:receive 900001# LRANGE uid:1001:receive 0 9=&gt;900001,893201,939922,..22 23. Part 3Redis 23 24. VM swap 24 25. CPU = CPU - 125 26. / 26 27. Part 4 http://redis.io/http://blog.nosqlfan.comhttp://www.slideshare.net/search/slideshow?searchfrom=header&amp;q=redis 27 28. Another Introduce to Redishttp://jiaqing.me 2012-05-21 -END-28</p>