Module: HTTParty::Icebox::ClassMethods
- Defined in:
- lib/p3-tvdb/httparty_icebox.rb
Instance Method Summary collapse
-
#cache(options = {}) ⇒ Object
Enable caching and set cache options Returns memoized cache object.
Instance Method Details
#cache(options = {}) ⇒ Object
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'
58 59 60 61 62 63 |
# File 'lib/p3-tvdb/httparty_icebox.rb', line 58 def cache(={}) [:store] ||= 'memory' [:timeout] ||= 60 logger = [:logger] @cache ||= Cache.new( .delete(:store), ) end |