Sha256: 97832cd2cccfd74f38aceff61d91734f063c0724979db347590d93afbbc81fd8
Contents?: true
Size: 1.33 KB
Versions: 4
Compression:
Stored size: 1.33 KB
Contents
module CacheAdvance class CacheSet attr_reader :named_caches attr_reader :qualifiers attr_reader :plugins def initialize(store) @store, @named_caches, @qualifiers, @plugins = store, {}, {}, [] end def setup_complete end def apply(cache_name, request, options, &block) cache_name = cache_name.to_sym if CacheAdvance.caching_enabled named_cache = @named_caches[cache_name] raise UnknownNamedCacheException if named_cache.nil? named_cache.value_for(request, options, &block) else block.call end end def add_qualifier(name, proc) @qualifiers[name] = proc end def add_plugin(plugin) @plugins << plugin end def add_named_cache(name, options) name = name.to_sym @named_caches[name] = NamedCache.new(name, options, self, @store) end def define_caches yield Mapper.new(self) end def create_sweepers @sweeper_type.initialize_observed(@named_caches.values.map { |c| c.expiration_types }.flatten.compact.uniq) end def expire_for_class(class_name) @named_caches.values.each do |named_cache| named_cache.expire_for(class_name) end end def sweeper_type=(type) @sweeper_type = type end end end
Version data entries
4 entries across 4 versions & 2 rubygems