Class: Sass::CacheStores::Memory
- Inherits:
-
Base
- Object
- Base
- Sass::CacheStores::Memory
- Defined in:
- .ruby-sass/lib/sass/cache_stores/memory.rb
Overview
A backend for the Sass cache using in-process memory.
Class Method Summary (collapse)
-
._load(repr) ⇒ Object
If we deserialize this class, just make a new empty one.
Instance Method Summary (collapse)
-
#_dump(depth) ⇒ Object
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.
-
#initialize ⇒ Memory
constructor
Create a new, empty cache store.
-
#reset! ⇒ Object
Destructively clear the cache.
- #retrieve(key, sha) ⇒ Object
- #store(key, sha, obj) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize ⇒ Memory
Create a new, empty cache store.
23 24 25 |
# File '.ruby-sass/lib/sass/cache_stores/memory.rb', line 23 def initialize @contents = {} end |
Constructor Details
#initialize ⇒ Memory
Create a new, empty cache store.
23 24 25 |
# File '.ruby-sass/lib/sass/cache_stores/memory.rb', line 23 def initialize @contents = {} end |
Class Method Details
Instance Method Details
#_dump(depth) ⇒ Object
Since the Sass::CacheStores::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.
11 12 13 |
# File '.ruby-sass/lib/sass/cache_stores/memory.rb', line 11 def _dump(depth) "" end |
#reset! ⇒ Object
Destructively clear the cache.
41 42 43 |
# File '.ruby-sass/lib/sass/cache_stores/memory.rb', line 41 def reset! @contents = {} end |
#retrieve(key, sha) ⇒ Object
28 29 30 31 32 33 |
# File '.ruby-sass/lib/sass/cache_stores/memory.rb', line 28 def retrieve(key, sha) return unless @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 |
#store(key, sha, obj) ⇒ Object
36 37 38 |
# File '.ruby-sass/lib/sass/cache_stores/memory.rb', line 36 def store(key, sha, obj) @contents[key] = {:sha => sha, :obj => obj} end |