Class: Sass::CacheStores::Chain
- Inherits:
-
Base
- Object
- Base
- Sass::CacheStores::Chain
- Defined in:
- /var/www/sass-pages/.sass/lib/sass/cache_stores/chain.rb
Overview
A meta-cache that chains multiple caches together. Specifically:
- All
#stores are passed to all caches. #retrieves are passed to each cache until one has a hit.- When one cache has a hit, the value is
#stored in all earlier caches.
Instance Method Summary
- - (Chain) initialize(*caches) constructor Create a new cache chaining the given caches.
- - retrieve(key, sha)
- - store(key, sha, obj)
Methods inherited from Base
Constructor Details
- (Chain) initialize(*caches)
Create a new cache chaining the given caches.
13 14 15 |
# File '/var/www/sass-pages/.sass/lib/sass/cache_stores/chain.rb', line 13
def initialize(*caches)
@caches = caches
end
|
Instance Method Details
- retrieve(key, sha)
23 24 25 26 27 28 29 30 |
# File '/var/www/sass-pages/.sass/lib/sass/cache_stores/chain.rb', line 23
def retrieve(key, sha)
@caches.each_with_index do |c, i|
next unless obj = c.retrieve(key, sha)
@caches[0...i].each {|c| c.store(key, sha, obj)}
return obj
end
nil
end
|
- store(key, sha, obj)
18 19 20 |
# File '/var/www/sass-pages/.sass/lib/sass/cache_stores/chain.rb', line 18
def store(key, sha, obj)
@caches.each {|c| c.store(key, sha, obj)}
end
|