Module: Exchange::Cache

Defined in:
lib/exchange/cache/base.rb,
lib/exchange/cache/file.rb,
lib/exchange/cache/rails.rb,
lib/exchange/cache/redis.rb,
lib/exchange/cache/memory.rb,
lib/exchange/cache/no_cache.rb,
lib/exchange/cache/memcached.rb,
lib/exchange/cache/configuration.rb

Overview

The cache module. All Classes handling caching for this gem have to be placed here. Allows easy extension with own caching solutions as shown in the example below.

Examples:

Write your own caching module

module Cache
  class MyCustomCache < Base    # A cache class has to have the method "cached".
    # The cache Base is a singleton and forwards the method "cached"
    # to the instance
    #

    def cached api, opts={}, &block      # generate the storage with key(api, opts[:at]) and you will get a 
      # unique key to store in your cache
      #
      # Your code goes here

    end
  end
end

# Now, you can configure your Caching solution in the configuration. The Symbol will get camelcased and constantized
#
Exchange.configuration.cache.subclass = :my_custom_cache

# Have fun, and don't forget to write tests.

Since:

  • 0.1

Defined Under Namespace

Classes: Base, Configuration, File, Memcached, Memory, Rails, Redis

Constant Summary collapse

CachingWithoutBlockError =

The error getting thrown if caching is attempted without a given block

Since:

  • 0.1

Version:

  • 0.1

Class.new UsageError
NoCache =

A class to set caching to false

Author:

  • Beat Richartz

Since:

  • 0.3

Version:

  • 0.6

Class.new Base