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
190
Controllers suck.
damln
1
170
Rails et Heroku
damln
3
290
Capucine
damln
1
82
Other Decks in Programming
See All in Programming
1BRC--Nerd Sniping the Java Community
gunnarmorling
0
300
HUIT新歓2024「競技プログラミング、やってみませんか?」
slephy2784
1
250
スクラムガイドのスプリントレトロスペクティブを改めて読みかえしてみた / Re-reading the Sprint Retrospective Section in the Scrum Guide
mackey0225
3
320
Creating Retro-Style Photos Using Swift
ski
1
890
Introduction for Open Source Swift Workshop
giginet
PRO
0
1.1k
pixivアプリでマルチモジュールを実現するまで
gatosyocora
1
130
Javaエンジニアのための Nodejs/Nuxt3入門
hidekatsu_izuno
0
260
ログラスを支える設計標準について / loglass-design-standards
urmot
10
2.1k
CQRS/ES avec Symfony, c’est (trop) bien !
jeremyfreeagent
1
620
"config" ってなんだ? / What is "config"?
okashoi
0
210
try! Swift Tokyo 初参加報告LT
hinakko2
0
180
チームでモデリングを育てるうえで 考えたこと・気づいたこと / Cultivating Modeling in Teams: Thoughts and Insights
mackey0225
7
4.1k
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
41
12k
Designing with Data
zakiwarfel
95
4.8k
Build The Right Thing And Hit Your Dates
maggiecrowley
23
2k
Code Reviewing Like a Champion
maltzj
513
39k
How GitHub Uses GitHub to Build GitHub
holman
468
290k
Navigating Team Friction
lara
177
13k
Web development in the modern age
philhawksworth
201
10k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
24
2.3k
What the flash - Photography Introduction
edds
64
11k
A Philosophy of Restraint
colly
195
16k
Gamification - CAS2011
davidbonilla
76
4.6k
Why You Should Never Use an ORM
jnunemaker
PRO
50
8.6k
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