Skip to content

Instantly share code, notes, and snippets.

@Asmod4n
Created August 19, 2013 14:05
Show Gist options
  • Save Asmod4n/6269508 to your computer and use it in GitHub Desktop.
Save Asmod4n/6269508 to your computer and use it in GitHub Desktop.
Endless loop with redis-pool
source 'https://rubygems.org'
gem 'redis-pool'
gem 'celluloid-redis'
gem 'ohm'
require 'bundler/setup'
ENV['REDIS_URL'] = "unix:///path/to/redis.sock"
require 'celluloid/redis'
require 'redis/connection/celluloid'
require 'redis/pool'
require 'ohm'
POOL = Redis::Pool.new(size:5, db: 2)
Redis.current = POOL
module Ffl
module Model
class Post < Ohm::Model
def self.db
Redis.current
end
attribute :title
attribute :heading
attribute :body
attribute :etag
counter :hits
unique :title
end
end
end
20.times do |i| Ffl::Model::Post.create(title: "Titel #{i}", heading: "Überschrift #{i}", body: "Text #{i}") end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment