SlideShare uma empresa Scribd logo
1 de 18
Redis On Rails
Marc Beaupré-Pham
Lagoa.com
what is redis?
redis is key-value data structure store
basics
Q: Speed?
A: Fast. ~Memcached
Q: Persistence?
A: In Memory. Store to disk using
Snapshoting or Append-Only File (AOF)
Q: Guts?
A: Written in C
Single Threaded
Atomic commands
Zero Dependencies
Q: Installation?
A: sudo apt-get install redis-server
brew install redis
who else?
Many more…
+
gem ‘redis-rails’
gem 'hiredis', '~> 0.4.5'
pool
gem 'connection_pool’
$redis = ConnectionPool::Wrapper.new(:size => 5, :timeout => 3) do
Redis.new(:driver => :hiredis)
end
caching
redis-rails gives data cache, session store & HTTP cache
Rails.cache.write(‘key’,‘Hello Montreal.rb’)
session[:key] = ‘Hello Montreal.rb’
fresh_when last_modified: @posts.maximum(:updated_at)
why redis?
Expiring
Stores objects
lists
sets
hashes
strings
job queues
Examples:
Resque
Sidekiq
why redis?
Queues (through lists)
RPUSH LPUSH RPOP LPOP
pub/sub
Examples:
websockets
messaging
#comment.rb
after_create {
$redis.publish(’new_comment’, comment.attributes)
}
#node.js
var sub_client = redis.createClient();
sub_client.addListener('message', broadcastToClients);
why redis?
Stable
Fast
primary db?
data structure
-View Counts (incr)
-Metrics (incr)
-Who’s Online (w/ union)
$redis.with do |redis_client|
…
raise 'Unable to acquire resource' unless redis_client.multi do |r|
[r.SETNX(@key, @token),
r.SETNX(@token, @key)]
end.all?{|result| result == 1 }
…
end
Locks & Semaphores (setnx and del)
Features
Primitives
– Lists
– (sorted) Sets
– Hashes
– Strings
Pub/Sub
Queues (through lists)
Expiration

Mais conteúdo relacionado

Mais procurados

Ceph Day Berlin: Ceph and iSCSI in a high availability setup
Ceph Day Berlin: Ceph and iSCSI in a high availability setupCeph Day Berlin: Ceph and iSCSI in a high availability setup
Ceph Day Berlin: Ceph and iSCSI in a high availability setupCeph Community
 
Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redisTanu Siwag
 
Boost your website by running PHP on Nginx
Boost your website by running PHP on NginxBoost your website by running PHP on Nginx
Boost your website by running PHP on NginxHarald Zeitlhofer
 
The Need For Speed: Caching Fundamentals
The Need For Speed: Caching FundamentalsThe Need For Speed: Caching Fundamentals
The Need For Speed: Caching FundamentalsFrankie Jarrett
 
Aerospike DB and Storm for real-time analytics
Aerospike DB and Storm for real-time analyticsAerospike DB and Storm for real-time analytics
Aerospike DB and Storm for real-time analyticsAerospike
 
StripeEu Twistedbytes Presentation
StripeEu Twistedbytes PresentationStripeEu Twistedbytes Presentation
StripeEu Twistedbytes Presentationtwistedbytes
 
PHP projects beyond the LAMP stack
PHP projects beyond the LAMP stackPHP projects beyond the LAMP stack
PHP projects beyond the LAMP stackCodemotion
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisArnab Mitra
 
Combining Real-time and Batch Analytics with NoSQL, Storm and Hadoop - NoSQL ...
Combining Real-time and Batch Analytics with NoSQL, Storm and Hadoop - NoSQL ...Combining Real-time and Batch Analytics with NoSQL, Storm and Hadoop - NoSQL ...
Combining Real-time and Batch Analytics with NoSQL, Storm and Hadoop - NoSQL ...Aerospike
 
Rails Caching Secrets from the Edge
Rails Caching Secrets from the EdgeRails Caching Secrets from the Edge
Rails Caching Secrets from the EdgeMichael May
 
EWD 3 Training Course Part 17: Introduction to Global Storage Databases
EWD 3 Training Course Part 17: Introduction to Global Storage DatabasesEWD 3 Training Course Part 17: Introduction to Global Storage Databases
EWD 3 Training Course Part 17: Introduction to Global Storage DatabasesRob Tweed
 
Tales Of The Black Knight - Keeping EverythingMe running
Tales Of The Black Knight - Keeping EverythingMe runningTales Of The Black Knight - Keeping EverythingMe running
Tales Of The Black Knight - Keeping EverythingMe runningDvir Volk
 
Work WIth Redis and Perl
Work WIth Redis and PerlWork WIth Redis and Perl
Work WIth Redis and PerlBrett Estrade
 
Elasticsearch 1.x Cluster Installation (VirtualBox)
Elasticsearch 1.x Cluster Installation (VirtualBox)Elasticsearch 1.x Cluster Installation (VirtualBox)
Elasticsearch 1.x Cluster Installation (VirtualBox)Amir Sedighi
 
17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]Krisman Tarigan
 

Mais procurados (20)

Ceph Day Berlin: Ceph and iSCSI in a high availability setup
Ceph Day Berlin: Ceph and iSCSI in a high availability setupCeph Day Berlin: Ceph and iSCSI in a high availability setup
Ceph Day Berlin: Ceph and iSCSI in a high availability setup
 
Redis 101
Redis 101Redis 101
Redis 101
 
Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redis
 
Redis database
Redis databaseRedis database
Redis database
 
Boost your website by running PHP on Nginx
Boost your website by running PHP on NginxBoost your website by running PHP on Nginx
Boost your website by running PHP on Nginx
 
The Need For Speed: Caching Fundamentals
The Need For Speed: Caching FundamentalsThe Need For Speed: Caching Fundamentals
The Need For Speed: Caching Fundamentals
 
Aerospike DB and Storm for real-time analytics
Aerospike DB and Storm for real-time analyticsAerospike DB and Storm for real-time analytics
Aerospike DB and Storm for real-time analytics
 
StripeEu Twistedbytes Presentation
StripeEu Twistedbytes PresentationStripeEu Twistedbytes Presentation
StripeEu Twistedbytes Presentation
 
Mini-Training: To cache or not to cache
Mini-Training: To cache or not to cacheMini-Training: To cache or not to cache
Mini-Training: To cache or not to cache
 
PHP projects beyond the LAMP stack
PHP projects beyond the LAMP stackPHP projects beyond the LAMP stack
PHP projects beyond the LAMP stack
 
Running PHP on Nginx
Running PHP on NginxRunning PHP on Nginx
Running PHP on Nginx
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Combining Real-time and Batch Analytics with NoSQL, Storm and Hadoop - NoSQL ...
Combining Real-time and Batch Analytics with NoSQL, Storm and Hadoop - NoSQL ...Combining Real-time and Batch Analytics with NoSQL, Storm and Hadoop - NoSQL ...
Combining Real-time and Batch Analytics with NoSQL, Storm and Hadoop - NoSQL ...
 
Rails Caching Secrets from the Edge
Rails Caching Secrets from the EdgeRails Caching Secrets from the Edge
Rails Caching Secrets from the Edge
 
EWD 3 Training Course Part 17: Introduction to Global Storage Databases
EWD 3 Training Course Part 17: Introduction to Global Storage DatabasesEWD 3 Training Course Part 17: Introduction to Global Storage Databases
EWD 3 Training Course Part 17: Introduction to Global Storage Databases
 
Tales Of The Black Knight - Keeping EverythingMe running
Tales Of The Black Knight - Keeping EverythingMe runningTales Of The Black Knight - Keeping EverythingMe running
Tales Of The Black Knight - Keeping EverythingMe running
 
Work WIth Redis and Perl
Work WIth Redis and PerlWork WIth Redis and Perl
Work WIth Redis and Perl
 
Elasticsearch 1.x Cluster Installation (VirtualBox)
Elasticsearch 1.x Cluster Installation (VirtualBox)Elasticsearch 1.x Cluster Installation (VirtualBox)
Elasticsearch 1.x Cluster Installation (VirtualBox)
 
17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]
 

Destaque

Redis on Rails at RedDotRubyConference 2012
Redis on Rails at RedDotRubyConference 2012Redis on Rails at RedDotRubyConference 2012
Redis on Rails at RedDotRubyConference 2012Obie Fernandez
 
Living bythe Book Observation
Living bythe Book ObservationLiving bythe Book Observation
Living bythe Book Observationguest60214a
 
Redis on Rails (RedDotRubyConf 2012)
Redis on Rails (RedDotRubyConf 2012)Redis on Rails (RedDotRubyConf 2012)
Redis on Rails (RedDotRubyConf 2012)Obie Fernandez
 
Living by the Book Week 1
Living by the Book Week 1Living by the Book Week 1
Living by the Book Week 1John Shapiro
 
iMasters DevCommerce 2016 - A difícil tarefa de ser TI numa empresa de varejo...
iMasters DevCommerce 2016 - A difícil tarefa de ser TI numa empresa de varejo...iMasters DevCommerce 2016 - A difícil tarefa de ser TI numa empresa de varejo...
iMasters DevCommerce 2016 - A difícil tarefa de ser TI numa empresa de varejo...Leonardo "Hackin" Freire
 
Living by the Book Week 2
Living by the Book Week 2Living by the Book Week 2
Living by the Book Week 2John Shapiro
 

Destaque (11)

Hacking Twitter API [ Giran Siege ]
Hacking Twitter API [ Giran Siege ]Hacking Twitter API [ Giran Siege ]
Hacking Twitter API [ Giran Siege ]
 
Redis on Rails at RedDotRubyConference 2012
Redis on Rails at RedDotRubyConference 2012Redis on Rails at RedDotRubyConference 2012
Redis on Rails at RedDotRubyConference 2012
 
Photoimpa
PhotoimpaPhotoimpa
Photoimpa
 
Brochure Masters NL
Brochure Masters NLBrochure Masters NL
Brochure Masters NL
 
Living bythe Book Observation
Living bythe Book ObservationLiving bythe Book Observation
Living bythe Book Observation
 
Redis on Rails (RedDotRubyConf 2012)
Redis on Rails (RedDotRubyConf 2012)Redis on Rails (RedDotRubyConf 2012)
Redis on Rails (RedDotRubyConf 2012)
 
Living by the Book Week 1
Living by the Book Week 1Living by the Book Week 1
Living by the Book Week 1
 
iMasters DevCommerce 2016 - A difícil tarefa de ser TI numa empresa de varejo...
iMasters DevCommerce 2016 - A difícil tarefa de ser TI numa empresa de varejo...iMasters DevCommerce 2016 - A difícil tarefa de ser TI numa empresa de varejo...
iMasters DevCommerce 2016 - A difícil tarefa de ser TI numa empresa de varejo...
 
The bible.w1
The bible.w1The bible.w1
The bible.w1
 
HTML5 for Mobile
HTML5 for MobileHTML5 for Mobile
HTML5 for Mobile
 
Living by the Book Week 2
Living by the Book Week 2Living by the Book Week 2
Living by the Book Week 2
 

Semelhante a Redis

Beyond relational database - Building high performance websites using Redis a...
Beyond relational database - Building high performance websites using Redis a...Beyond relational database - Building high performance websites using Redis a...
Beyond relational database - Building high performance websites using Redis a...Dinh Pham
 
(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep DiveAmazon Web Services
 
quickguide-einnovator-10-redis-admin
quickguide-einnovator-10-redis-adminquickguide-einnovator-10-redis-admin
quickguide-einnovator-10-redis-adminjorgesimao71
 
Redispresentation apac2012
Redispresentation apac2012Redispresentation apac2012
Redispresentation apac2012Ankur Gupta
 
Redis and its many use cases
Redis and its many use casesRedis and its many use cases
Redis and its many use casesChristian Joudrey
 
This is redis - feature and usecase
This is redis - feature and usecaseThis is redis - feature and usecase
This is redis - feature and usecaseKris Jeong
 
phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialphptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialWim Godden
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Wim Godden
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariJoseph Scott
 
Clug 2011 March web server optimisation
Clug 2011 March  web server optimisationClug 2011 March  web server optimisation
Clug 2011 March web server optimisationgrooverdan
 
Developing a Redis Module - Hackathon Kickoff
 Developing a Redis Module - Hackathon Kickoff Developing a Redis Module - Hackathon Kickoff
Developing a Redis Module - Hackathon KickoffItamar Haber
 
Zend Con 2008 Slides
Zend Con 2008 SlidesZend Con 2008 Slides
Zend Con 2008 Slidesmkherlakian
 
Amazon Elasticache Deep Dive - March 2017 AWS Online Tech Talks
Amazon Elasticache Deep Dive - March 2017 AWS Online Tech TalksAmazon Elasticache Deep Dive - March 2017 AWS Online Tech Talks
Amazon Elasticache Deep Dive - March 2017 AWS Online Tech TalksAmazon Web Services
 

Semelhante a Redis (20)

Beyond relational database - Building high performance websites using Redis a...
Beyond relational database - Building high performance websites using Redis a...Beyond relational database - Building high performance websites using Redis a...
Beyond relational database - Building high performance websites using Redis a...
 
(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive(DAT407) Amazon ElastiCache: Deep Dive
(DAT407) Amazon ElastiCache: Deep Dive
 
Redis
RedisRedis
Redis
 
quickguide-einnovator-10-redis-admin
quickguide-einnovator-10-redis-adminquickguide-einnovator-10-redis-admin
quickguide-einnovator-10-redis-admin
 
Redispresentation apac2012
Redispresentation apac2012Redispresentation apac2012
Redispresentation apac2012
 
Redis and its many use cases
Redis and its many use casesRedis and its many use cases
Redis and its many use cases
 
This is redis - feature and usecase
This is redis - feature and usecaseThis is redis - feature and usecase
This is redis - feature and usecase
 
phptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorialphptek13 - Caching and tuning fun tutorial
phptek13 - Caching and tuning fun tutorial
 
Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012Caching and tuning fun for high scalability @ FOSDEM 2012
Caching and tuning fun for high scalability @ FOSDEM 2012
 
Java at lifeblob
Java at lifeblobJava at lifeblob
Java at lifeblob
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Redis by-hari
Redis by-hariRedis by-hari
Redis by-hari
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Redis 101
Redis 101Redis 101
Redis 101
 
Redis acc
Redis accRedis acc
Redis acc
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
 
Clug 2011 March web server optimisation
Clug 2011 March  web server optimisationClug 2011 March  web server optimisation
Clug 2011 March web server optimisation
 
Developing a Redis Module - Hackathon Kickoff
 Developing a Redis Module - Hackathon Kickoff Developing a Redis Module - Hackathon Kickoff
Developing a Redis Module - Hackathon Kickoff
 
Zend Con 2008 Slides
Zend Con 2008 SlidesZend Con 2008 Slides
Zend Con 2008 Slides
 
Amazon Elasticache Deep Dive - March 2017 AWS Online Tech Talks
Amazon Elasticache Deep Dive - March 2017 AWS Online Tech TalksAmazon Elasticache Deep Dive - March 2017 AWS Online Tech Talks
Amazon Elasticache Deep Dive - March 2017 AWS Online Tech Talks
 

Último

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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
 
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
 

Último (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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...
 
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...
 

Redis

Notas do Editor

  1. So, what's it all about, I thought I would just start by quickly going over the basics. But I'm not going to dwell for too long about what redis is, because I want this talk to really be more about what you can do with it.
  2. So, speed-wise, most benchmarks put it at a little bit slower or a little bit faster than memcached. It doesn't really matter which, it's fast.It's an in-memory data store, which backs up to disk.
  3. It's written in C, single threaded, atomic commands and installs easily with zero dependies.
  4. Who uses it? A bunch of companies. Really more than I wanted to put in this slide, so consider this just a small slice.
  5. Alright, now let's get down to what we're here for, is some talk about RUBY! Getting started is pretty darned simple, just throw a line in your gemfile and you're good to go.
  6. Oh, but oups, we forgot something!Never forget to leave home without your C bindings! hiredis does that for us.Whew, narroly missed that one.
  7. So, moving on, it's usually a good idea, if you're going to be dealing with a DB connection in an environment where you might have threading, to give yourself a pool of connections to work with. This way, you aren't waiting for one command to finish before you do something else.
  8. Alright, now that we've set up redis to our liking, what can we do with it.Well, I feel like the quickest and easier win you can get with redis is to use it for some caching. Just configure rails to use Redis in the application.rb file, and then you're good to go. And it just works. This isn't a rails tutorial, so I'm not going to really go in to any more details. It just works.
  9. So, what make redis maybe better caching that something like a file store. Well, other than speed, there is the fact that it can store objects other than just strings. It can handle lists, sets, hashes and strings like a champ. It also has built in support for expirations, so that's nice too.
  10. Apart from simple caching, you can also use it as a great job queue. From what I've been reading, it seems to be a best practice to keep jobs our of your database, despite the widespread use of things like DJ. And, there are a few job queues out there for ruby+rails that do make make use of redis as a job queue.
  11. So, what makes redis maybe better than a DB for jobs? Well, factors include the fact that with Redid'sbuiltin support for lists, you can also treat them like queues. With push and pop commands available on any list, redis makes lists work like queues just like we want.
  12. Yet another really great feature of redis is pub/sub support. Pub sub isn't something every company has a need for, but once you're already using redis for your caching and queueing needs, it just makes sense to give redis yet another responsibility. I guess we're all here because we think the future of technology is in the cloud (or you just love ruby enough to put up with all these rails guys/gals), then you might have used websockets in your application. And if you have, then you might have decided to go with a technology other than ruby on rails. Perhaps something more evented. So, whatever your technology choice, pub/sub comes very much in handy when trying to communicate with services around your infrastructure. And, with clients available in so many languages, choosing redis is never hard.
  13. So, why choose redis for this particular task? Well, do you really need any more reasons other than the fact that it is stable and fast? I think the other reason we've ever had a redis machine go down was because it ran out of membory or disk space.
  14. Alright, what about using redis as your primary database? Well, I can't reallly comment on that since I've never done it. It might be a good idea if that’s your thing. But, the point I want to re-iterate, is that I don’t see it as an either-or decision. I think you should use both, and divide the work according them depending the specifics of your use case.
  15. Alright, there's still more you can use redis for. A lot of people get a lot of value out of using redis for for other tasks around their infrastructure. Use cases you might want to consider using redis with are counting page views, recording metrics. This is really nice if you use redis's built in `increment` function.Also, maintaining a set of users that are presently online. This works really well if you combine redis's built-in union support, so you can find out who's online, and also a friend of Alice.
  16. Another more esoteric use case might be maintaining some sort of resource lock across your network. You can have a machine attempt to set a key if it doesn't already exist. That gives you the ability for one machine to hold a resource. Then, the machine can delete the key when they're done. You can even set the key to expire after a period of time if you want to timeout usage.This is an example where I attempt to set aquire a resource, and give a user of that resource a token. So, I'm combining a few features of redis here, including the `set if not existant`, `multi` for multiple command execution which I spoke of earlier, and then later we can delete those key-value pairs with an atomic multi delete operation.
  17. So yeah, redis gives you a lot in 1 simple package. There are many more features that I didn't speak up, like string maniputation, hashes, set functions, sorted sets, scripting and much more.What I really wanted to get across with this talk, is that redis is much more than a database and can be used in many creative ways. There doesn't exist another package out there that gives you so much, with such simplicity. So, my advice is to use redis everywhere. It gives you a head start in many key, early areas, and can scale with you for years to come. And, once you have it, many of your other technology choices just fall in to place around it. It also plays nice with any other service you might want to set up around your servers.