I am looking for something where I can keep an entire Rails based Model stored in Redis. There is Redis Objects that is found here https://github.com/nateware/redis-objects but that only works when your model is already backed by something like ActiveRecord and it requires a unique id generator. I don't wish to make an ActiveRecord backed model, as I want to persist everything directly into memory and not into the database.
Is there a drop in tool that I can use right now that'll let me do things like:
and it'll retrieve me the RedisBackedModel from Redis?
I've used Ohm before for storing searches that expire after a couple hours; it's pretty nice. I think DataMapper also has a redis adapter, although I've never used it. Here's some Ohm code for what I think you're after:
class RedisBackedModel < Ohm::Model attribute :name index :name end rbm = RedisBackedModel.create :name => "foo" rbm.id # => 1 # Search by name: RedisBackedModel.find(:name => "foo") # Search by id (like AR-style model.get(id)): RedisBackedModel