Class: Sass::CacheStores::Memory

Inherits:
Base
  • Object
show all
Defined in:
lib/sass/cache_stores/memory.rb

Overview

A backend for the Sass cache using in-process memory.

Instance Method Summary collapse

Methods inherited from Base

#_retrieve, #_store, #key

Constructor Details

#initializeMemory

Create a new, empty cache store.


23
24
25
# File 'lib/sass/cache_stores/memory.rb', line 23

def initialize
  @contents = {}
end

Instance Method Details

#reset!

Destructively clear the cache.


42
43
44
# File 'lib/sass/cache_stores/memory.rb', line 42

def reset!
  @contents = {}
end

#retrieve(key, sha)

See Also:


28
29
30
31
32
33
34
# 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

#store(key, sha, obj)

See Also:


37
38
39
# File 'lib/sass/cache_stores/memory.rb', line 37

def store(key, sha, obj)
  @contents[key] = {:sha => sha, :obj => obj}
end