elephas

Build Status Dependency Status Code Climate

A storage agnostic caching framework.

http://sw.cow.tc/elephas

http://rdoc.info/gems/elephas

Usage

The usage of the framework is really simple.

At first you have to setup a provider (that is, a storage) for the Elephas. By default it uses an internal hash, and also Rails is supported.

Elephas::Cache.provider = Elephas::Providers::RubyOnRails.new

After that, you can query the framework for a value use the use method.

You should also pass a block to the method, so that the framework use that for computing the value of the cache entry.

value = Elephas::Cache.use("KEY") do |options|
  "VALUE"
end
# => "VALUE"

The next time you issue this call, the block won't be called.

The block takes an argument, which contains all the options for the entry.

You can see Elephas::Cache.setup_options documentation to see what options are supported.

For now, you just have to know that you can set the :ttl option to specify how long the value will stay in the cache (in milliseconds). Setting it to a non-positive value means to never cache the value.

See documentation for more informations.

You're done!

Contributing to elephas

Copyright

Copyright (C) 2013 and above Shogun (shogun_panda@me.com).

Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.