Redis

2,803 views

Published on

Présentation faite lors de l'apéro Ruby d'Avril.
Plus d'infos :
http://rubybdx.org/
et
http://twitter.com/rubybdx

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,803
On SlideShare
0
From Embeds
0
Number of Embeds
902
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Redis

  1. 1. REDISRedis is an open source, advanced key-value store. It is often referred to as a datastructure server since keys can containstrings, hashes,lists, sets and sorted sets. gem ‘redis’
  2. 2. USE Cache Session (cookies)gem ‘redis-rails’App::Application.config.session_store:redis_store,:servers => "redis://127.0.0.1:6379/1"
  3. 3. 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’)
  4. 4. ENVIRONMENTResque (+ Scheduler) Ohm EventMachine PubSub
  5. 5. Resque (+Scheduler) Fast ² Queue YAML - Crongem ‘resque’gem ‘resque-scheduler’,git: git://github.com/bvandenbos/resque-scheduler
  6. 6. Ohm ORM Flexible Extensiblegem ‘ohm’gem ‘ohm-contrib’
  7. 7. Ohm (model)class User < Ohm::Model attribute :name attribute :nickname include Ohm::Validations extend ActiveModel::Naming include ActiveModel::AttributeMethods index :name collection :messages, Messageend
  8. 8. Ohm (model)class User < Ohm::Model def persisted? false end def to_hash super.merge({:name => self.name}) endend
  9. 9. Ohm (model)class Message < Ohm::Model attribute :content include Ohm::Validations extend ActiveModel::Naming include ActiveModel::AttributeMethods index :content reference :user, Userend
  10. 10. EventMachine Node.js for Ruby em-WebSocket em-redisgem ‘eventmachine’gem ‘em-redis’
  11. 11. PubSub$redis =new Redis(:host => ‘127.0.0.7’, :port => 6379, :db => 0)$redis.subscribe(‘my_channel’) do |on| on.message do |channel, msg| puts msg endend$redis.publish(‘my_channel’, ‘content’)$redis.publish(‘my_channel.*’, ‘content’)
  12. 12. PRODUCTION Debian / OSX Heroku Easy (foreman)
  13. 13. @ damlnwww.dln.name

×