README.mkd

redis-native_hash

Tools to help expose Redis' powerful Hash type through a familiar Ruby Hash interface.
NativeHash provides a general solution for exposing reasonably sized Redis hashes as
Ruby hashes, including sane and transparent transactions, nested hash support, and automatic
serialization of complex data types. BigHash is provided to
efficiently handle big or even enormous Redis hashes. LazyHash is a convenient proxy
for NativeHash useful when you aren't sure the hash will be read (useful for sessions).

Also included is Rack middleware to store sessions in Redis hashes, and a two Rails caching
solution, one using Redis hashes and the other using Redis strings.

Using as a Rails session store

Using Redis string-based caching implementation

Only the string based implementation is able to properly handle automatic expiration, so it is preferred.

Add the following line to the appropriate environment config in config/environments/

config.cache_store =:redis_store

To set a cache expiration, use a line like this:

config.cache_store = [:redis_store, :expires_in => 24.hours]

Client helpers

This gem adds a useful Redis::ClientHelper module to simplify both connection sharing and using multiple connections.
Using Redis::Client.default= you can set the connection all future instances of NativeHash/BigHash/LazyHash
will use.