Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Redis with Ruby
Search
Damian Le Nouaille
April 04, 2012
Programming
4
260
Redis with Ruby
Damian Le Nouaille
April 04, 2012
Tweet
Share
More Decks by Damian Le Nouaille
See All by Damian Le Nouaille
Re-Think your workflow with a piano
damln
0
150
Optimize or Die Tryin'
damln
1
220
Rails YAML vuln.
damln
1
220
Rails et Heroku
damln
3
340
Capucine
damln
1
140
Other Decks in Programming
See All in Programming
CSC307 Lecture 09
javiergs
PRO
1
830
メルカリのリーダビリティチームが取り組む、AI時代のスケーラブルな品質文化
cloverrose
2
510
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
540
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
450
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
400
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
190
登壇資料を作る時に意識していること #登壇資料_findy
konifar
4
1k
Data-Centric Kaggle
isax1015
2
770
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
160
Patterns of Patterns
denyspoltorak
0
1.4k
AgentCoreとHuman in the Loop
har1101
5
230
CSC307 Lecture 08
javiergs
PRO
0
670
Featured
See All Featured
The SEO identity crisis: Don't let AI make you average
varn
0
67
Testing 201, or: Great Expectations
jmmastey
46
8k
Abbi's Birthday
coloredviolet
1
4.7k
Darren the Foodie - Storyboard
khoart
PRO
2
2.4k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
55
Practical Orchestrator
shlominoach
191
11k
A better future with KSS
kneath
240
18k
Typedesign – Prime Four
hannesfritz
42
2.9k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
GitHub's CSS Performance
jonrohan
1032
470k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
RailsConf 2023
tenderlove
30
1.3k
Transcript
None
REDIS Redis is an open source, advanced key- value store.
It is often referred to as a data structure server since keys can contain strings, hashes,lists, sets and sorted sets. gem ‘redis’
USE Cache Session (cookies) gem ‘redis-rails’ App::Application.config.session_store :redis_store, :servers =>
"redis://127.0.0.1:6379/1"
Commands $redis = new Redis(:host => ‘127.0.0.7’, :port => 6379,
:db => 0) $redis.set(‘my_key’, ‘awesome’) $redis.get(‘my_key’) => ‘awesome’ $redis.del(‘my_key’)
ENVIRONMENT Resque (+ Scheduler) Ohm EventMachine PubSub
Resque (+Scheduler) Fast ² Queue YAML - Cron gem ‘resque’
gem ‘resque-scheduler’, git: 'git://github.com/bvandenbos/resque-scheduler'
Ohm ORM Flexible Extensible gem ‘ohm’ gem ‘ohm-contrib’
Ohm (model) class User < Ohm::Model attribute :name attribute :nickname
include Ohm::Validations extend ActiveModel::Naming include ActiveModel::AttributeMethods index :name collection :messages, Message end
Ohm (model) class User < Ohm::Model def persisted? false end
def to_hash super.merge({:name => self.name}) end end
Ohm (model) class Message < Ohm::Model attribute :content include Ohm::Validations
extend ActiveModel::Naming include ActiveModel::AttributeMethods index :content reference :user, User end
EventMachine Node.js for Ruby em-WebSocket em-redis gem ‘eventmachine’ gem ‘em-redis’
PubSub $redis = new Redis(:host => ‘127.0.0.7’, :port => 6379,
:db => 0) $redis.publish(‘my_channel’, ‘content’) $redis.subscribe(‘my_channel’) do |on| on.message do |channel, msg| puts msg end end $redis.publish(‘my_channel.*’, ‘content’)
PRODUCTION Debian / OSX Heroku Easy (foreman)
@ damln www.dln.name