redis-collections

This gem allows you to associate collections of models (currently only ActiveRecord or Mongoid models) with a Ruby object through Redis.

It uses redis-objects behind the scenes to associate a list of model ids with an object.

~~~ class Foo include Redis::Collections

collection :bars

def id 1 end end

class Bar < ActiveRecord::Base end

foo = Foo.new bar = Bar.create bar2 = Bar.create

foo.bars << bar << bar2 foo.bars.all => [#<Bar id: 2>, #<Bar id: 1>

foo.bars.ids = [1, 2] foo.bars.all => [#<Bar id: 1>, #<Bar id: 2>]

foo.bars.move(bar, 1) foo.bars.all => [#<Bar id: 2>, #<Bar id: 1>]

foo.bars.increment_counter(bar) foo.counters => {“1” => “1”}

foo.bars.delete(bar) foo.bars.all => [#<Bar id: 2>] ~~~

Contributing to redis-collections

Copyright © 2013 Evan Whalen. See LICENSE.txt for further details.