Redis on Rails                           Obie FernandezTuesday, May 22, 2012
Salvatore Sanfilippo                        aka “antirez”                        Pieter NoordhuisTuesday, May 22, 2012
It’s a sidekick to your regular database!Tuesday, May 22, 2012
Tuesday, May 22, 2012
Tuesday, May 22, 2012
clues that you    should consider    using Redis   •SQL database seems overkill   •update-only data (only inserted)   •non...
Why Redis                and not something                      else?Tuesday, May 22, 2012
Redis                           is                        blazing                         fast!Tuesday, May 22, 2012
Source: http://antirez.com/post/redis-memcached-benchmark.htmlTuesday, May 22, 2012
Redis                        DurabilityTuesday, May 22, 2012
:REDIS0001<FE>^@^C^RAttendee:27:events^B<C1><A8>^@                        1335369284<C1><A6>^@                        1335...
################################ SNAPSHOTTING       #################################       #       # Save the DB on disk:...
Redis AOF                        (Append Only File)Tuesday, May 22, 2012
AOF optionsTuesday, May 22, 2012
Redis                        has lots                           of                        featuresTuesday, May 22, 2012
Tuesday, May 22, 2012
Photo Credit: http://www.flickr.com/photos/blingrocksTuesday, May 22, 2012
Nest                Object-oriented Keys for Redis                github.com/soveran/nest                    • Creates a R...
Tuesday, May 22, 2012
Tuesday, May 22, 2012
Example App    http://github.com/obie/redis_on_railsTuesday, May 22, 2012
Tuesday, May 22, 2012
Adding properties                         to ActiveRecord                             ExampleTuesday, May 22, 2012
RedisProps                Easy annotation of ActiveRecord objects                http://github.com/obie/redis_props       ...
...Redis hash                           ExampleTuesday, May 22, 2012
Basic Twitter                        functionality in about                          60 lines of RubyTuesday, May 22, 2012
Examples                of intersections                and unionsTuesday, May 22, 2012
Tuesday, May 22, 2012
Events - Sorted sets                             ExampleTuesday, May 22, 2012
SortedSet                        zunionstore and                          zinterstore                           ExamplesTu...
RedisObjects                Map Redis types directly to Ruby objects                github.com/nateware/redis-objectsTuesd...
RedisObjects                    •Values                    •Lists                    •Sets                    •SortedSets ...
Atomic Counter                           ExampleTuesday, May 22, 2012
Testing Tips                    •Don’t bother mocking out Redis                    •Select a different database number    ...
Tuesday, May 22, 2012
Rails                        Console                          ♥s                         RedisTuesday, May 22, 2012
Redis                          makes                        you more                         creativeTuesday, May 22, 2012
Obie Fernandez     Thanks...                               obiefernandez@gmail.com                                        ...
Upcoming SlideShare
Loading in...5
×

Redis on Rails (RedDotRubyConf 2012)

11,940

Published on

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
11,940
On Slideshare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
0
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

Redis on Rails (RedDotRubyConf 2012)

  1. 1. Redis on Rails Obie FernandezTuesday, May 22, 2012
  2. 2. Salvatore Sanfilippo aka “antirez” Pieter NoordhuisTuesday, May 22, 2012
  3. 3. It’s a sidekick to your regular database!Tuesday, May 22, 2012
  4. 4. Tuesday, May 22, 2012
  5. 5. Tuesday, May 22, 2012
  6. 6. clues that you should consider using Redis •SQL database seems overkill •update-only data (only inserted) •non-transactional needs •no relations with other tablesTuesday, May 22, 2012
  7. 7. Why Redis and not something else?Tuesday, May 22, 2012
  8. 8. Redis is blazing fast!Tuesday, May 22, 2012
  9. 9. Source: http://antirez.com/post/redis-memcached-benchmark.htmlTuesday, May 22, 2012
  10. 10. Redis DurabilityTuesday, May 22, 2012
  11. 11. :REDIS0001<FE>^@^C^RAttendee:27:events^B<C1><A8>^@ 1335369284<C1><A6>^@ 1335369244^C^TAttendee:1:events:11^A<C0>J 1335364980^@^PAttendee:10:name^SJorge H. Cuadrado C^@ESCConference:8:breakevenpoint<C1><A0>^O^C^TAttendee:1:events: 13^B<C0>a 1335365085<C0>g 1335365112^@^PAttendee:22:name Mark Bates^D^RConference:1:notes^A<C0>^A<C3>=@C^Xthese are my notes, lala ^C@^A^E mo ^^<A0>ESC^LIll addd som 4^Bore^C^QAttendee:4:events^F<C0>^] 1335314963<C0>^_ 1335314968<C0>D 1335335712<C0>E RDB 1335335715<C0>^S 1335314271<C0>^T 1335314300^C^RAttendee:16:events^C<C0>k 1335365137<C0>^ 1335365082<C0>V files 1335365068^B^UAttendee: 11:followers^B<C0>^A<C0>^O^D^ZAttendeeRegisteredEvent: 65^B^Kattendee_id^A1^Mconference_id^A8^D^ AttendeeUnregisteredEvent:64^B^Kattendee_id^A1 ^Mconference_id^A8^C^TAttendee:13:events:1^A<C0>a 1335365085^D^AttendeeUnregisteredEvent: 66^B^Kattendee_id^A1^Mconference_id^A8^D^] AttendeeUnregisteredEvent: 170^B^Kattendee_id^B25^Mconference_id^A8^C^UAttendee:21:events: 21^M<C1><97>^@ 1335365767<C1><8F>^@ 1335365733<C1><92>^@ 1335365741<C1><9B>^@ 1335365879<C1><93>^@ 1335365742<C1><94>^@ 1335365743<C1><95>^@ 1335365744<C1><96>^@ 1335365746<C1><98>^@ 1335365783<C1><99>^@Tuesday, May 22, 2012
  12. 12. ################################ SNAPSHOTTING ################################# # # Save the DB on disk: # # save <seconds> <changes> # # Will save the DB if both the given number of seconds and # the given number of write operations against the DB occurred. # # In the example below the behaviour will be to save: # after 900 sec (15 min) if at least 1 key changed # after 300 sec (5 min) if at least 10 keys changed # after 60 sec if at least 10000 keys changed # # Note: you can disable saving at all commenting all the # "save" lines. save 900 1 save 300 10 save 60 10000Tuesday, May 22, 2012
  13. 13. Redis AOF (Append Only File)Tuesday, May 22, 2012
  14. 14. AOF optionsTuesday, May 22, 2012
  15. 15. Redis has lots of featuresTuesday, May 22, 2012
  16. 16. Tuesday, May 22, 2012
  17. 17. Photo Credit: http://www.flickr.com/photos/blingrocksTuesday, May 22, 2012
  18. 18. Nest Object-oriented Keys for Redis github.com/soveran/nest • Creates a Redis connection by default • Calls to_s for key representation • Really simple code / hack it for your needsTuesday, May 22, 2012
  19. 19. Tuesday, May 22, 2012
  20. 20. Tuesday, May 22, 2012
  21. 21. Example App http://github.com/obie/redis_on_railsTuesday, May 22, 2012
  22. 22. Tuesday, May 22, 2012
  23. 23. Adding properties to ActiveRecord ExampleTuesday, May 22, 2012
  24. 24. RedisProps Easy annotation of ActiveRecord objects http://github.com/obie/redis_props example: facebook_authentication.rbTuesday, May 22, 2012
  25. 25. ...Redis hash ExampleTuesday, May 22, 2012
  26. 26. Basic Twitter functionality in about 60 lines of RubyTuesday, May 22, 2012
  27. 27. Examples of intersections and unionsTuesday, May 22, 2012
  28. 28. Tuesday, May 22, 2012
  29. 29. Events - Sorted sets ExampleTuesday, May 22, 2012
  30. 30. SortedSet zunionstore and zinterstore ExamplesTuesday, May 22, 2012
  31. 31. RedisObjects Map Redis types directly to Ruby objects github.com/nateware/redis-objectsTuesday, May 22, 2012
  32. 32. RedisObjects •Values •Lists •Sets •SortedSets •Atomic Counters and LocksTuesday, May 22, 2012
  33. 33. Atomic Counter ExampleTuesday, May 22, 2012
  34. 34. Testing Tips •Don’t bother mocking out Redis •Select a different database number so you don’t clobber anything •Redis.current.flushdb is your friendTuesday, May 22, 2012
  35. 35. Tuesday, May 22, 2012
  36. 36. Rails Console ♥s RedisTuesday, May 22, 2012
  37. 37. Redis makes you more creativeTuesday, May 22, 2012
  38. 38. Obie Fernandez Thanks... obiefernandez@gmail.com @obie on twitter Example Code http://github.com/obie/redis_on_rails Slides available at my blog http://blog.obiefernandez.com Redis http://redis.io Check out DueProps http://dueprops.comTuesday, May 22, 2012

×