Greencache

A gem for caching data in Redis.

This gem caches data from slow services in Redis

This gem is also able to encrypt the cached results with Fernet if required.

Installation

Add this line to your application's Gemfile:

gem 'greencache'

And then execute:

$ bundle

Or install it yourself as:

$ gem install greencache

Usage


Greencache.configure do |c|
  c.redis = $redis
  c.secret = <some_long_hash>
  c.encrypt = true
end

value = Greencache.cache "unique_cache_key" do
  call_to_slow_service
end

Configuration

Several configuration options are available to use that defined the behaviour of greencache.

:redis Connection to redis
:secret If encrypting, what secret should be used. See [Fernet](https://github.com/fernet/fernet-rb) README for more information
:encrypt Should cached data be encrypted (boolean)
:skip_cache Should the cache be skipped. Useful in test environments (boolean)
:logged Standard logger object to use for logging
:log_prefix String to prefix to l2met compatible log lines
:cache_time Time (in seconds) to cache data for before expiring

Testing

Specs to come ;)

Contributing

  1. Fork it ( https://github.com/neilmiddleton/greencache/fork )
  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