module HTTParty::Icebox::ClassMethods

Public Instance Methods

cache(options={}) click to toggle source

Enable caching and set cache options Returns memoized cache object

Following options are available, default values are in []:

store

Storage mechanism for cached data (memory, filesystem, your own) [memory]

timeout

Cache expiration in seconds [60]

logger

Path to logfile or logger instance [STDOUT]

Any additional options are passed to the Cache constructor

Usage:

# Enable caching in HTTParty, in memory, for 1 minute
cache # Use default values

# Enable caching in HTTParty, on filesystem (/tmp), for 10 minutes
cache :store => 'file', :timeout => 600, :location => '/tmp/'

# Use your own cache store (see AbstractStore class below)
cache :store => 'memcached', :timeout => 600, :server => '192.168.1.1:1001'
# File lib/shin/httparty_icebox.rb, line 58
def cache(options={})
  options[:store]   ||= 'memory'
  options[:timeout] ||= 60
  logger = options[:logger]
  @cache ||= Cache.new( options.delete(:store), options )
end