6. clues that you
should consider
using Redis
•SQL database seems overkill
•update-only data (only inserted)
•non-transactional needs
•no relations with other tables
Tuesday, May 22, 2012
7. Why Redis
and not something
else?
Tuesday, May 22, 2012
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^LI'll 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. ################################ 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 10000
Tuesday, May 22, 2012
13. Redis AOF
(Append Only File)
Tuesday, May 22, 2012
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 needs
Tuesday, May 22, 2012
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
friend
Tuesday, May 22, 2012
37. Redis
makes
you more
creative
Tuesday, May 22, 2012
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.com
Tuesday, May 22, 2012