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
120
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
RuboCop: Modularity and AST Insights
koic
2
1.4k
[NG India] Event-Based State Management with NgRx SignalStore
markostanimirovic
1
160
Enterprise Web App. Development (1): Build Tool Training Ver. 5
knakagawa
1
120
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
0
110
Defying Front-End Inertia: Inertia.js on Rails
skryukov
0
490
設計の本質:コード、システム、そして組織へ / The Essence of Design: To Code, Systems, and Organizations
nrslib
4
620
Optimizing JRuby 10
headius
0
350
MCP調べてみました! / Exploring MCP
uhzz
2
2.3k
趣味全開のAITuber開発
kokushin
0
200
サービスレベルを管理してアジャイルを加速しよう!! / slm-accelerate-agility
tomoyakitaura
1
180
On-the-fly Suggestions of Rewriting Method Deprecations
ohbarye
1
2.8k
Youtube Lofier - Chrome拡張開発
ninikoko
0
2.4k
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
53
13k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
13
1.4k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Fontdeck: Realign not Redesign
paulrobertlloyd
83
5.5k
GraphQLとの向き合い方2022年版
quramy
46
14k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
21k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Testing 201, or: Great Expectations
jmmastey
42
7.5k
Into the Great Unknown - MozCon
thekraken
37
1.7k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.8k
Visualization
eitanlees
146
16k
The Cult of Friendly URLs
andyhume
78
6.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