Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Simple, ActiveModel-compatible model persistance in Redis

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 redis-persistence.gemspec

Redis Persistence

Redis::Persistence is a lightweight object persistence framework, fully compatible with ActiveModel, based on Redis, easily used standalone or within Rails applications.


$ gem install redis-persistence


  • 100% Rails compatibility
  • 100% ActiveModel compatibility: callbacks, validations, serialization, ...
  • No crazy has_many-type of semantics
  • Auto-incrementing IDs
  • Defining default values for properties
  • Casting properties as built-in or custom classes
  • Convenient "dot access" to properties (
  • Support for "collections" of embedded objects (eg. article » comments)
  • Automatic conversion of UTC-formatted strings to Time objects
  • Small: 1 file, ~ 200 lines of code
  • Fast: ~2000 saves/sec, ~6000 finds/sec

Basic example

    require 'redis/persistence'

    Redis::Persistence.config.redis =
    # => #<Redis client v2.2.2 connected to redis:// (Redis v2.4.1)>

    class Article
      include Redis::Persistence

      property :title
      property :body
      property :author, :default  => '(Unknown)'
      property :created

    Article.create title: 'The Thing', body: 'So, in the beginning...', created:

    article = Article.find(1)
    # => <Article: {"id"=>1, "title"=>"The Thing", ...}>

    # => The Thing!

    # => 2011

    article.title = 'The Cabin'
    # => <Article: {"id"=>1, "title"=>"The Cabin", ...}>

See the examples/article.rb for full example.

(c) 2011, Social Insider, s.r.o., released under the MIT License.

Something went wrong with that request. Please try again.