class Pagelime::CacheEngine
Public Class Methods
new(config)
click to toggle source
# File lib/pagelime/cache_engine.rb, line 6 def initialize(config) @config = config end
Public Instance Methods
clear_page(page_path)
click to toggle source
# File lib/pagelime/cache_engine.rb, line 24 def clear_page(page_path) cache_key = generate_region_cache_key(page_path) delete cache_key end
delete(key)
click to toggle source
# File lib/pagelime/cache_engine.rb, line 46 def delete(key) @config.cache.delete(key) if @config.cache end
fetch(key, options = {}) { || ... }
click to toggle source
Generic cache methods
# File lib/pagelime/cache_engine.rb, line 38 def fetch(key, options = {}, &block) if @config.cache @config.cache.fetch(key, fetch_options, &block) else yield end end
fetch_path(page_path, &block)
click to toggle source
CMS-specific methods
# File lib/pagelime/cache_engine.rb, line 12 def fetch_path(page_path, &block) cache_key = generate_region_cache_key(page_path) fetch(cache_key, fetch_options, &block) end
Private Instance Methods
fetch_options()
click to toggle source
# File lib/pagelime/cache_engine.rb, line 64 def fetch_options @config.cache_fetch_options || {} end
generate_region_cache_key(page_path)
click to toggle source
# File lib/pagelime/cache_engine.rb, line 52 def generate_region_cache_key(page_path) if @config.generate_region_cache_key.respond_to? :call @config.generate_region_cache_key.call(page_path) else "pagelime:cms:page:#{Base64.encode64(page_path)}" end end