Sha256: e56988cb4b30528a1fc13f8307f3601787cc0b39487d34a9f9d36fb966854b98
Contents?: true
Size: 682 Bytes
Versions: 5
Compression:
Stored size: 682 Bytes
Contents
#:enddoc: module RailsConnector class Cache def initialize(options = {}) @fallback_backend, @cache_prefix = options[:fallback_backend], options[:cache_prefix] @cache = {} end def read(key) value = @cache[key] if !value && @fallback_backend value = @fallback_backend.read(cache_key_for_fallback_backend(key)) @cache[key] = value end value end def write(key, value) @fallback_backend.write(cache_key_for_fallback_backend(key), value) if @fallback_backend @cache[key] = value end private def cache_key_for_fallback_backend(key) @cache_prefix ? "#{@cache_prefix}/#{key}" : key end end end # module RailsConnector
Version data entries
5 entries across 5 versions & 1 rubygems