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
230
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
93
Optimize or Die Tryin'
damln
1
170
Rails YAML vuln.
damln
1
200
Controllers suck.
damln
1
170
Rails et Heroku
damln
3
290
Capucine
damln
1
83
Other Decks in Programming
See All in Programming
ServerAction で Progressive Enhancement はどこまで頑張れるか? / progressive-enhancement-with-server-action
takefumiyoshii
6
390
Next.js App Router
quramy
11
1.6k
CDKコントリビュートの最初の壁を越えよう! -簡単issueの見つけ方-
badmintoncryer
3
180
dbtのドメイン分割による データ基盤の改善とDigdagとの連携
sakama
0
440
初心者のためのRubyKaigi入門/RubyKaigi Introduction
a_matsuda
8
1.4k
Scalable Customer Journey Orchestration (CJO)
lewuathe
0
410
はてなにおける CSS Modules、及び CSS Modules に足りないもの / CSS Modules in Hatena, and CSS Modules missing parts
mizdra
7
970
Build Apps for iOS, Android & Desktop in 100% Kotlin With Compose Multiplatform (mDevCamp 2024)
zsmb
0
420
PostmanでAPIの動作確認が楽になった話
h455h1
0
180
What We Can Learn From OSS
inouehi
0
430
Tailwind CSSを本気でカスタマイズする方法
fsubal
14
5.5k
障害対応を起点としたもっといい開発と運用のサイクル作りのためにできること / Hatena Enginner Seminar #29
polamjag
0
350
Featured
See All Featured
Building an army of robots
kneath
300
41k
Build The Right Thing And Hit Your Dates
maggiecrowley
25
2k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
Art, The Web, and Tiny UX
lynnandtonic
290
19k
Music & Morning Musume
bryan
41
5.6k
Side Projects
sachag
451
41k
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
Learning to Love Humans: Emotional Interface Design
aarron
267
39k
Stop Working from a Prison Cell
hatefulcrawdad
267
19k
WebSockets: Embracing the real-time Web
robhawkes
59
7k
Making the Leap to Tech Lead
cromwellryan
125
8.5k
GitHub's CSS Performance
jonrohan
1025
450k
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