Created
August 19, 2013 14:05
-
-
Save Asmod4n/6269508 to your computer and use it in GitHub Desktop.
Endless loop with redis-pool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'redis-pool' | |
gem 'celluloid-redis' | |
gem 'ohm' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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