An object caching library using Redis.
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.coveralls.yml
.gitignore
.travis.yml
Gemfile
LICENSE.txt
README.md
Rakefile
reserve.gemspec

README.md

reserve - caching library based around Redis EXPIRE

Build Status Coverage Status Inline docs

This gem provides simple object caching support using Redis.

It works around the concept of "faulting"; you request an object from the cache and if it already exists it will return the cached object. If not, it'll execute the associated block to generate it instead.

Using Redis' EXPIRE functionality, the cached object can be set to automatically disappear after a set period of time.

Installation

Reserve isn't (yet) on RubyGems, so add the repo to your Gemfile:

gem 'reserve', :git => 'https://github.com/nickcharlton/reserve-ruby.git'

Usage

reserve = Reserve.new(Redis.new)

# store an item with a given key
item = reserve.store :item do
  { value: "this is item" }
end

item # => { value: "this is item" }

Both Reserve.new and store accept a hash of options, but they're a little bit different for each:

For Reserve.new:

default_timeout: 3600 # the default timeout to use with store.
key_prefix: 'reserve' # the prefix to use in Redis.

For store:

timeout: 3600 # the timeout to use when storing this item.
skip_cache: true # skip the cache in this invokation (great for testing).

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Author

Copyright (c) 2014 Nick Charlton nick@nickcharlton.net