A storage agnostic caching framework.
The usage of the framework is really simple.
At first you have to setup a cache object with a backend (that is, a storage) for the Elephas. By default it uses an internal hash, and also Rails is supported.
cache = Elephas::Cache.new(Elephas::Backends::RubyOnRails.new)
After that, you can query the framework for a value use the
You should also pass a block to the method, so that the framework use that for computing the value of the cache entry.
value = 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.
Contributing to elephas
- Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
- Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
- Fork the project.
- Start a feature/bugfix branch.
- Commit and push until you are happy with your contribution.
- Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
- Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright (C) 2013 and above Shogun (email@example.com).
Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.