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

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/chain.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/cache_stores/chain.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/cache_stores/chain.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/sass-3.7.4/lib/sass/cache_stores/chain.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/sass-3.7.4/lib/sass/cache_stores/chain.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/cache_stores/chain.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/cache_stores/chain.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/cache_stores/chain.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/cache_stores/chain.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/cache_stores/chain.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/cache_stores/chain.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/cache_stores/chain.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/sass-3.7.4/lib/sass/cache_stores/chain.rb
sass-3.7.4 lib/sass/cache_stores/chain.rb
brakeman-4.4.0 bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/chain.rb
sass-3.7.3 lib/sass/cache_stores/chain.rb
sass-3.7.2 lib/sass/cache_stores/chain.rb
sass-3.7.1 lib/sass/cache_stores/chain.rb
sass-3.7.0 lib/sass/cache_stores/chain.rb
sass-3.6.0 lib/sass/cache_stores/chain.rb