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
240
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
100
Optimize or Die Tryin'
damln
1
180
Rails YAML vuln.
damln
1
200
Controllers suck.
damln
1
180
Rails et Heroku
damln
3
300
Capucine
damln
1
110
Other Decks in Programming
See All in Programming
42 best practices for Symfony, a decade later
tucksaun
1
180
14 Years of iOS: Lessons and Key Points
seyfoyun
1
770
Go の GC の不得意な部分を克服したい
taiyow
2
760
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
180
From Translations to Multi Dimension Entities
alexanderschranz
2
130
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
270
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
nekko cloudにおけるProxmox VE利用事例
irumaru
3
420
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
450
N.E.X.T LEVEL
pluu
2
300
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
250
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
610
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
88
5.7k
Fireside Chat
paigeccino
34
3.1k
Making Projects Easy
brettharned
116
5.9k
The Cult of Friendly URLs
andyhume
78
6.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Making the Leap to Tech Lead
cromwellryan
133
9k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
160
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
How GitHub (no longer) Works
holman
311
140k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
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