SlideShare a Scribd company logo
1 of 38
Redis on Rails
                           Obie Fernandez




Tuesday, May 22, 2012
Salvatore Sanfilippo
                        aka “antirez”


                        Pieter Noordhuis

Tuesday, 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-transactional needs
   •no relations with other tables
Tuesday, May 22, 2012
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.html
Tuesday, May 22, 2012
Redis
                        Durability
Tuesday, May 22, 2012
: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
################################ 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
Redis AOF
                        (Append Only File)




Tuesday, May 22, 2012
AOF options




Tuesday, May 22, 2012
Redis
                        has lots
                           of
                        features
Tuesday, May 22, 2012
Tuesday, May 22, 2012
Photo Credit: http://www.flickr.com/photos/blingrocks
Tuesday, May 22, 2012
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
Tuesday, May 22, 2012
Tuesday, May 22, 2012
Example App
    http://github.com/obie/redis_on_rails




Tuesday, May 22, 2012
Tuesday, May 22, 2012
Adding properties
                         to ActiveRecord
                             Example


Tuesday, May 22, 2012
RedisProps
                Easy annotation of ActiveRecord objects
                http://github.com/obie/redis_props




                           example: facebook_authentication.rb



Tuesday, May 22, 2012
...Redis hash
                           Example


Tuesday, May 22, 2012
Basic Twitter
                        functionality in about
                          60 lines of Ruby


Tuesday, May 22, 2012
Examples
                of intersections
                and unions

Tuesday, May 22, 2012
Tuesday, May 22, 2012
Events - Sorted sets
                             Example


Tuesday, May 22, 2012
SortedSet
                        zunionstore and
                          zinterstore
                           Examples

Tuesday, May 22, 2012
RedisObjects
                Map Redis types directly to Ruby objects
                github.com/nateware/redis-objects
Tuesday, May 22, 2012
RedisObjects
                    •Values
                    •Lists
                    •Sets
                    •SortedSets
                    •Atomic Counters and Locks

Tuesday, May 22, 2012
Atomic Counter
                           Example


Tuesday, May 22, 2012
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
Tuesday, May 22, 2012
Rails
                        Console
                          ♥s
                         Redis
Tuesday, May 22, 2012
Redis
                          makes
                        you more
                         creative
Tuesday, May 22, 2012
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

More Related Content

Viewers also liked

Viewers also liked (13)

Benzene Market Price Report Weekly_Nov 06_2015
Benzene Market Price Report Weekly_Nov 06_2015Benzene Market Price Report Weekly_Nov 06_2015
Benzene Market Price Report Weekly_Nov 06_2015
 
SD WiFi v3基板の説明
SD WiFi v3基板の説明SD WiFi v3基板の説明
SD WiFi v3基板の説明
 
Good morning wishes wallpaper, images, quotes
Good morning wishes wallpaper, images, quotesGood morning wishes wallpaper, images, quotes
Good morning wishes wallpaper, images, quotes
 
Unternehmen 4.0: Warum Digitalisierung?
Unternehmen 4.0: Warum Digitalisierung?Unternehmen 4.0: Warum Digitalisierung?
Unternehmen 4.0: Warum Digitalisierung?
 
Ego
EgoEgo
Ego
 
Fear and hope in the internet of things
Fear and hope in the internet of thingsFear and hope in the internet of things
Fear and hope in the internet of things
 
Expresion corporal para adultos mayores
Expresion corporal para adultos mayoresExpresion corporal para adultos mayores
Expresion corporal para adultos mayores
 
Конкурс «Контент – марафон»
Конкурс «Контент – марафон»Конкурс «Контент – марафон»
Конкурс «Контент – марафон»
 
Signals Plug-In - Digital Technology in the School Curriculum
Signals Plug-In - Digital Technology in the School CurriculumSignals Plug-In - Digital Technology in the School Curriculum
Signals Plug-In - Digital Technology in the School Curriculum
 
Trigonometry
TrigonometryTrigonometry
Trigonometry
 
Ramcharitra manas
Ramcharitra manasRamcharitra manas
Ramcharitra manas
 
Scrum
ScrumScrum
Scrum
 
Digitalisierung im Customer Care Management: Konsequenzen für den Kundenserv...
Digitalisierung im Customer Care Management: Konsequenzen für den Kundenserv...Digitalisierung im Customer Care Management: Konsequenzen für den Kundenserv...
Digitalisierung im Customer Care Management: Konsequenzen für den Kundenserv...
 

Similar to Redis on Rails (RedDotRubyConf 2012)

Node Access in Drupal 7 (and Drupal 8)
Node Access in Drupal 7 (and Drupal 8)Node Access in Drupal 7 (and Drupal 8)
Node Access in Drupal 7 (and Drupal 8)nyccamp
 
Symfony2 and MongoDB
Symfony2 and MongoDBSymfony2 and MongoDB
Symfony2 and MongoDBPablo Godel
 
Mansoura University CSED & Nozom web development sprint
Mansoura University CSED & Nozom web development sprintMansoura University CSED & Nozom web development sprint
Mansoura University CSED & Nozom web development sprintAl Sayed Gamal
 
PlayNice.ly: Using Redis to store all our data, hahaha (Redis London Meetup)
PlayNice.ly: Using Redis to store all our data, hahaha (Redis London Meetup)PlayNice.ly: Using Redis to store all our data, hahaha (Redis London Meetup)
PlayNice.ly: Using Redis to store all our data, hahaha (Redis London Meetup)Adam Charnock
 
THE STATE OF GLOBAL INFRASTRUCTURE PERFORMANCE from Structure 2012
THE STATE OF GLOBAL INFRASTRUCTURE PERFORMANCE from Structure 2012THE STATE OF GLOBAL INFRASTRUCTURE PERFORMANCE from Structure 2012
THE STATE OF GLOBAL INFRASTRUCTURE PERFORMANCE from Structure 2012Gigaom
 
UX: What Not to Do
UX: What Not to DoUX: What Not to Do
UX: What Not to DoRob Surrency
 
Architecting large Node.js applications
Architecting large Node.js applicationsArchitecting large Node.js applications
Architecting large Node.js applicationsSergi Mansilla
 
Day 27 order of operations day 3
Day 27 order of operations day 3Day 27 order of operations day 3
Day 27 order of operations day 3Erik Tjersland
 
Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013Max Klymyshyn
 
Como escalar aplicações PHP
Como escalar aplicações PHPComo escalar aplicações PHP
Como escalar aplicações PHPAugusto Pascutti
 
Cypher Query Language
Cypher Query Language Cypher Query Language
Cypher Query Language graphdevroom
 
REST & Hypermedia: the missing links and why you need them - Ruby Hoedown 2012
REST & Hypermedia: the missing links and why you need them - Ruby Hoedown 2012REST & Hypermedia: the missing links and why you need them - Ruby Hoedown 2012
REST & Hypermedia: the missing links and why you need them - Ruby Hoedown 2012Phil Harvey
 
CLOUD LOCK-IN AND THE MYTH OF OPEN APIS at Structure 2012
CLOUD LOCK-IN AND THE MYTH OF OPEN APIS at Structure 2012CLOUD LOCK-IN AND THE MYTH OF OPEN APIS at Structure 2012
CLOUD LOCK-IN AND THE MYTH OF OPEN APIS at Structure 2012Gigaom
 
Speed is Essential for a Great Web Experience (Digicure - Copenhagen)
Speed is Essential for a Great Web Experience (Digicure - Copenhagen)Speed is Essential for a Great Web Experience (Digicure - Copenhagen)
Speed is Essential for a Great Web Experience (Digicure - Copenhagen)Andy Davies
 

Similar to Redis on Rails (RedDotRubyConf 2012) (19)

Node Access in Drupal 7 (and Drupal 8)
Node Access in Drupal 7 (and Drupal 8)Node Access in Drupal 7 (and Drupal 8)
Node Access in Drupal 7 (and Drupal 8)
 
Symfony2 and MongoDB
Symfony2 and MongoDBSymfony2 and MongoDB
Symfony2 and MongoDB
 
QCON SP 2012
QCON SP 2012QCON SP 2012
QCON SP 2012
 
Mansoura University CSED & Nozom web development sprint
Mansoura University CSED & Nozom web development sprintMansoura University CSED & Nozom web development sprint
Mansoura University CSED & Nozom web development sprint
 
Aegir
AegirAegir
Aegir
 
PlayNice.ly: Using Redis to store all our data, hahaha (Redis London Meetup)
PlayNice.ly: Using Redis to store all our data, hahaha (Redis London Meetup)PlayNice.ly: Using Redis to store all our data, hahaha (Redis London Meetup)
PlayNice.ly: Using Redis to store all our data, hahaha (Redis London Meetup)
 
THE STATE OF GLOBAL INFRASTRUCTURE PERFORMANCE from Structure 2012
THE STATE OF GLOBAL INFRASTRUCTURE PERFORMANCE from Structure 2012THE STATE OF GLOBAL INFRASTRUCTURE PERFORMANCE from Structure 2012
THE STATE OF GLOBAL INFRASTRUCTURE PERFORMANCE from Structure 2012
 
UX: What Not to Do
UX: What Not to DoUX: What Not to Do
UX: What Not to Do
 
Architecting large Node.js applications
Architecting large Node.js applicationsArchitecting large Node.js applications
Architecting large Node.js applications
 
Day 27 order of operations day 3
Day 27 order of operations day 3Day 27 order of operations day 3
Day 27 order of operations day 3
 
RDBMS vs NoSQL
RDBMS vs NoSQLRDBMS vs NoSQL
RDBMS vs NoSQL
 
Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013
 
Como escalar aplicações PHP
Como escalar aplicações PHPComo escalar aplicações PHP
Como escalar aplicações PHP
 
Cypher Query Language
Cypher Query Language Cypher Query Language
Cypher Query Language
 
REST & Hypermedia: the missing links and why you need them - Ruby Hoedown 2012
REST & Hypermedia: the missing links and why you need them - Ruby Hoedown 2012REST & Hypermedia: the missing links and why you need them - Ruby Hoedown 2012
REST & Hypermedia: the missing links and why you need them - Ruby Hoedown 2012
 
CLOUD LOCK-IN AND THE MYTH OF OPEN APIS at Structure 2012
CLOUD LOCK-IN AND THE MYTH OF OPEN APIS at Structure 2012CLOUD LOCK-IN AND THE MYTH OF OPEN APIS at Structure 2012
CLOUD LOCK-IN AND THE MYTH OF OPEN APIS at Structure 2012
 
Speed is Essential for a Great Web Experience (Digicure - Copenhagen)
Speed is Essential for a Great Web Experience (Digicure - Copenhagen)Speed is Essential for a Great Web Experience (Digicure - Copenhagen)
Speed is Essential for a Great Web Experience (Digicure - Copenhagen)
 
lecture_32.pptx
lecture_32.pptxlecture_32.pptx
lecture_32.pptx
 
Lecture 32
Lecture 32Lecture 32
Lecture 32
 

Recently uploaded

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Redis on Rails (RedDotRubyConf 2012)

  • 1. Redis on Rails Obie Fernandez Tuesday, May 22, 2012
  • 2. Salvatore Sanfilippo aka “antirez” Pieter Noordhuis Tuesday, May 22, 2012
  • 3. It’s a sidekick to your regular database! Tuesday, May 22, 2012
  • 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
  • 8. Redis is blazing fast! Tuesday, May 22, 2012
  • 10. Redis Durability 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
  • 15. Redis has lots of features 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
  • 21. Example App http://github.com/obie/redis_on_rails Tuesday, May 22, 2012
  • 23. Adding properties to ActiveRecord Example Tuesday, May 22, 2012
  • 24. RedisProps Easy annotation of ActiveRecord objects http://github.com/obie/redis_props example: facebook_authentication.rb Tuesday, May 22, 2012
  • 25. ...Redis hash Example Tuesday, May 22, 2012
  • 26. Basic Twitter functionality in about 60 lines of Ruby Tuesday, May 22, 2012
  • 27. Examples of intersections and unions Tuesday, May 22, 2012
  • 29. Events - Sorted sets Example Tuesday, May 22, 2012
  • 30. SortedSet zunionstore and zinterstore Examples Tuesday, May 22, 2012
  • 31. RedisObjects Map Redis types directly to Ruby objects github.com/nateware/redis-objects Tuesday, May 22, 2012
  • 32. RedisObjects •Values •Lists •Sets •SortedSets •Atomic Counters and Locks Tuesday, May 22, 2012
  • 33. Atomic Counter Example 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
  • 36. Rails Console ♥s Redis 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