Project

reserve

0.0
No commit activity in last 3 years
No release in over 3 years
An object caching library for Redis.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0
>= 0
>= 0

Runtime

~> 3.1.0
 Project Readme

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