Sha256: e9937d7672f6c9e86ea02d9d3e4e59d9695f68b67cf37af53ec44aaae30c335f
Contents?: true
Size: 953 Bytes
Versions: 137
Compression:
Stored size: 953 Bytes
Contents
module Sass module CacheStores # A meta-cache that chains multiple caches together. # Specifically: # # * All `#store`s are passed to all caches. # * `#retrieve`s are passed to each cache until one has a hit. # * When one cache has a hit, the value is `#store`d in all earlier caches. class Chain < Base # Create a new cache chaining the given caches. # # @param caches [Array<Sass::CacheStores::Base>] The caches to chain. def initialize(*caches) @caches = caches end # @see Base#store def store(key, sha, obj) @caches.each {|c| c.store(key, sha, obj)} end # @see Base#retrieve def retrieve(key, sha) @caches.each_with_index do |c, i| obj = c.retrieve(key, sha) next unless obj @caches[0...i].each {|prev| prev.store(key, sha, obj)} return obj end nil end end end end
Version data entries
137 entries across 134 versions & 9 rubygems