Project

dry_ice

0.0
No release in over 3 years
Low commit activity in last 3 years
Cache responses in HTTParty models
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.13.1
 Project Readme

DryIce - Caching for HTTParty

Code Climate

Description

Cache responses in HTTParty models. Every response from a resource which has a non 0 max-age header will be cached for the appropriate amount of time in the cache you provide it.

Based off https://github.com/sachse/httparty-icebox

Installation

RubyGems

You can install the latest Film Buff gem using RubyGems

gem install dry_ice

GitHub

Alternatively you can check out the latest code directly from Github

git clone http://github.com/homeflow/dry_ice.git

Usage

Any class which includes the HTTParty module can include HTTParty::DryIce and get access to a cache class method.

class AnAPI

  include HTTParty
  include HTTParty::DryIce
  base_uri 'example.com'
  
  cache Rails.cache

end

The cache method accepts any instance which quacks like a ActiveSupport cache. That means you can use the built in Rails caches, something like Redis Store or your own custom rolled class as long as it responds to the methods:

  • read
  • write (taking an option :expires_in => seconds)
  • exit?
  • delete

Contribute

Fork the project, implement your changes in it's own branch, and send a pull request to me. I'll gladly consider any help or ideas.

Contributors

This project was based off the excellent httparty-icebox gem: https://github.com/sachse/httparty-icebox. It's contributors are listed below.

  • Karel Minarik (Original creator through a gist)
  • Martyn Loughran - Major parts of this code are based on the architecture of ApiCache.
  • David Heinemeier Hansson - Other parts are inspired by the ActiveSupport::Cache in Ruby On Rails.
  • Amit Chakradeo - For pointing out response objects have to be stored marshalled on FS.
  • Marlin Forbes - For pointing out the query parameters have to be included in the cache key.
  • ramieblatt - Original Memcached store.