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
110
Optimize or Die Tryin'
damln
1
190
Rails YAML vuln.
damln
1
210
Controllers suck.
damln
1
180
Rails et Heroku
damln
3
310
Capucine
damln
1
110
Other Decks in Programming
See All in Programming
Jakarta EE meets AI
ivargrimstad
0
890
SwiftUI移行のためのインプレッショントラッキング基盤の構築
kokihirokawa
0
190
5分で理解する SOLID 原則 #phpcon_nagoya
shogogg
1
430
CloudRun, Spanner に対する負荷試験の反省と オブザーバビリティによるアプローチ
oyasumipants
1
210
PHPのバージョンアップ時にも役立ったAST
matsuo_atsushi
0
250
Lambdaの監視、できてますか?Datadogを用いてLambdaを見守ろう
nealle
2
850
The Price of Micro Frontends… and Your Alternatives @bastacon 2025 in Frankfurt
manfredsteyer
PRO
0
300
Google Cloudとo11yで実現するアプリケーション開発者主体のDB改善
nnaka2992
1
160
AWS CDKにおけるL2 Constructの仕組み / aws-cdk-l2-construct
gotok365
3
170
責務と認知負荷を整える! 抽象レベルを意識した関心の分離
yahiru
9
1.7k
Modern Angular with Signals and Signal StoreNew Rules for Your Architecture @bastacon 2025 in Frankfurt
manfredsteyer
PRO
0
150
CDKを使ったPagerDuty連携インフラのテンプレート化
shibuya_shogo
0
130
Featured
See All Featured
BBQ
matthewcrist
87
9.5k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
Adopting Sorbet at Scale
ufuk
75
9.2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
366
25k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Practical Orchestrator
shlominoach
186
10k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.2k
Six Lessons from altMBA
skipperchong
27
3.6k
A Philosophy of Restraint
colly
203
16k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.5k
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