Sha256: eacfb494798cb96bcd2c501e69c69e4b523b2fca8349e20ef422a2617836f597

Contents?: true

Size: 1.27 KB

Versions: 23

Compression:

Stored size: 1.27 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, version, sha)
        if @contents.has_key?(key)
          return unless @contents[key][:version] == version
          return unless @contents[key][:sha] == sha
          return @contents[key][:contents]
        end
      end
      
      # @see Base#_store
      def _store(key, version, sha, contents)
        @contents[key] = {
          :version => version,
          :sha => sha,
          :contents => contents
        }
      end
      
      # Destructively clear the cache.
      def reset!
        @contents = {}
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
haml-3.1.0 vendor/sass/lib/sass/cache_stores/memory.rb
sass-3.1.0.alpha.214 lib/sass/cache_stores/memory.rb
sass-3.1.0.alpha.210 lib/sass/cache_stores/memory.rb
haml-3.1.0.alpha.147 vendor/sass/lib/sass/cache_stores/memory.rb
sass-3.1.0.alpha.206 lib/sass/cache_stores/memory.rb
sass-3.1.0.alpha.205 lib/sass/cache_stores/memory.rb
sass-3.1.0.alpha.204 lib/sass/cache_stores/memory.rb
haml-3.1.0.alpha.145 vendor/sass/lib/sass/cache_stores/memory.rb
haml-3.1.0.alpha.144 vendor/sass/lib/sass/cache_stores/memory.rb
haml-3.1.0.alpha.141 vendor/sass/lib/sass/cache_stores/memory.rb
sass-3.1.0.alpha.200 lib/sass/cache_stores/memory.rb
sass-3.1.0.alpha.51 lib/sass/cache_stores/memory.rb
haml-3.1.0.alpha.37 vendor/sass/lib/sass/cache_stores/memory.rb
sass-3.1.0.alpha.50 lib/sass/cache_stores/memory.rb
sass-3.1.0.alpha.49 lib/sass/cache_stores/memory.rb
sass-3.1.0.alpha.48 lib/sass/cache_stores/memory.rb
sass-3.1.0.alpha.47 lib/sass/cache_stores/memory.rb
sass-3.1.0.alpha.46 lib/sass/cache_stores/memory.rb
sass-3.1.0.alpha.45 lib/sass/cache_stores/memory.rb
sass-3.1.0.alpha.44 lib/sass/cache_stores/memory.rb