Sha256: 1d91b221de84382f56df292d1e47616ed41ccde2278ad5f56257b65d39016f9c

Contents?: true

Size: 1.17 KB

Versions: 584

Compression:

Stored size: 1.17 KB

Contents

module Sass
  module CacheStores
    # A backend for the Sass cache using in-process memory.
    class Memory < Base
      # Since the {Memory} store is stored in the Sass tree's options hash,
      # when the options get serialized as part of serializing the tree,
      # you get crazy exponential growth in the size of the cached objects
      # unless you don't dump the cache.
      #
      # @private
      def _dump(depth)
        ""
      end

      # If we deserialize this class, just make a new empty one.
      #
      # @private
      def self._load(repr)
        Memory.new
      end

      # Create a new, empty cache store.
      def initialize
        @contents = {}
      end

      # @see Base#retrieve
      def retrieve(key, sha)
        if @contents.has_key?(key)
          return unless @contents[key][:sha] == sha
          obj = @contents[key][:obj]
          obj.respond_to?(:deep_copy) ? obj.deep_copy : obj.dup
        end
      end

      # @see Base#store
      def store(key, sha, obj)
        @contents[key] = {:sha => sha, :obj => obj}
      end
      
      # Destructively clear the cache.
      def reset!
        @contents = {}
      end
    end
  end
end

Version data entries

584 entries across 298 versions & 17 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/sass-3.2.19/lib/sass/cache_stores/memory.rb
classiccms-0.7.5 vendor/bundle/gems/haml-3.1.5/vendor/sass/lib/sass/cache_stores/memory.rb
classiccms-0.7.5 vendor/bundle/gems/sass-3.1.17/lib/sass/cache_stores/memory.rb
classiccms-0.7.5 vendor/bundle/gems/haml-3.1.6/vendor/sass/lib/sass/cache_stores/memory.rb
classiccms-0.7.5 vendor/bundle/gems/sass-3.1.15/lib/sass/cache_stores/memory.rb
classiccms-0.7.5 vendor/bundle/gems/sass-3.1.18/lib/sass/cache_stores/memory.rb
classiccms-0.7.5 vendor/bundle/gems/haml-3.1.4/vendor/sass/lib/sass/cache_stores/memory.rb
classiccms-0.7.5 vendor/bundle/gems/sass-3.1.19/lib/sass/cache_stores/memory.rb
classiccms-0.7.4 vendor/bundle/gems/haml-3.1.4/vendor/sass/lib/sass/cache_stores/memory.rb
classiccms-0.7.4 vendor/bundle/gems/haml-3.1.5/vendor/sass/lib/sass/cache_stores/memory.rb
classiccms-0.7.4 vendor/bundle/gems/sass-3.1.19/lib/sass/cache_stores/memory.rb
classiccms-0.7.4 vendor/bundle/gems/sass-3.1.15/lib/sass/cache_stores/memory.rb
classiccms-0.7.4 vendor/bundle/gems/sass-3.1.17/lib/sass/cache_stores/memory.rb
classiccms-0.7.4 vendor/bundle/gems/sass-3.1.18/lib/sass/cache_stores/memory.rb
classiccms-0.7.4 vendor/bundle/gems/haml-3.1.6/vendor/sass/lib/sass/cache_stores/memory.rb
classiccms-0.7.3 vendor/bundle/gems/sass-3.1.15/lib/sass/cache_stores/memory.rb
classiccms-0.7.3 vendor/bundle/gems/haml-3.1.5/vendor/sass/lib/sass/cache_stores/memory.rb
classiccms-0.7.3 vendor/bundle/gems/haml-3.1.4/vendor/sass/lib/sass/cache_stores/memory.rb
classiccms-0.7.3 vendor/bundle/gems/sass-3.1.18/lib/sass/cache_stores/memory.rb
classiccms-0.7.3 vendor/bundle/gems/sass-3.1.19/lib/sass/cache_stores/memory.rb