A backend for the Sass cache using in-process memory.
If we deserialize this class, just make a new empty one.
@private
# File lib/sass/cache_stores/memory.rb, line 18 def self._load(repr) Memory.new end
Create a new, empty cache store.
# File lib/sass/cache_stores/memory.rb, line 23 def initialize @contents = {} end
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
# File lib/sass/cache_stores/memory.rb, line 11 def _dump(depth) "" end
Destructively clear the cache.
# File lib/sass/cache_stores/memory.rb, line 42 def reset! @contents = {} end
@see Sass::CacheStores::Base#retrieve
# File lib/sass/cache_stores/memory.rb, line 28 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 Sass::CacheStores::Base#store
# File lib/sass/cache_stores/memory.rb, line 37 def store(key, sha, obj) @contents[key] = {:sha => sha, :obj => obj} end