Project

jsoncache

0.0
No commit activity in last 3 years
No release in over 3 years
A simple JSON cache for caching data intended for usewith HTTP APIs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.4
 Project Readme

JSONCache Build Status

A simple JSON Cache for use with HTTP APIs.

Installation

Add this line to your application's Gemfile:

gem 'jsoncache'

And then execute:

$ bundle

Or install it yourself as:

$ gem install jsoncache

Usage

Include it in the class or module you want to use it in.

extend JSONCache

To enable caching for a method use the include class method cache.

cache :expensive_method, expiry: 300

Note: the cache method call has to come after the method definition.

Example

require 'jsoncache'

Class A
  extend JSONCache

  def expensive_method(args)
    # code
  end

  cache :expensive_method, expiry: 300
end

The cache method will the existing method and provide it with caching to the local filesystem. You can set a TTL (time to live) for the cache by setting the expiry value in seconds.