Class: Exchange::Cache::Base

Inherits:
Object
  • Object
show all
Extended by:
SingleForwardable
Includes:
Singleton
Defined in:
lib/exchange/cache/base.rb

Overview

The base Class for all Caching operations. Essentially generates a helper function for all cache classes to generate a key

Author:

  • Beat Richartz

Since:

  • 0.1

Version:

  • 0.6

Direct Known Subclasses

File, Memcached, Memory, Rails, Redis

Instance Method Summary collapse

Instance Method Details

#cached(api, opts = {}) { ... } ⇒ Object

returns The result of the block called This method has to be the same in all the cache classes in order for the configuration binding to work

Options Hash (opts):

  • :at (Time)

    is ignored for filecache, other than that is the time of the cached rate

  • :cache_period (Symbol)

    The period to cache for

Yields:

  • This method takes a mandatory block with an arity of 0 and calls it if no cached result is available

Raises:

Since:

  • 0.1


50
51
52
53
54
# File 'lib/exchange/cache/base.rb', line 50

def cached api, opts={}, &block
  raise_caching_needs_block! unless block_given?

  block.call
end