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

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
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
 
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
 
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 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
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 

Recently uploaded (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
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
 
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 Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 

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