Class: Pagelime::CacheEngine
- Inherits:
-
Object
- Object
- Pagelime::CacheEngine
- Defined in:
- lib/pagelime/cache_engine.rb
Instance Method Summary collapse
- #clear_page(page_path) ⇒ Object
- #clear_shared ⇒ Object
- #delete(key) ⇒ Object
-
#fetch(key, options = {}, &block) ⇒ Object
Generic cache methods.
-
#fetch_path(page_path, &block) ⇒ Object
CMS-specific methods.
- #fetch_shared(&block) ⇒ Object
-
#initialize(config) ⇒ CacheEngine
constructor
A new instance of CacheEngine.
Constructor Details
#initialize(config) ⇒ CacheEngine
Returns a new instance of CacheEngine.
6 7 8 |
# File 'lib/pagelime/cache_engine.rb', line 6 def initialize(config) @config = config end |
Instance Method Details
#clear_page(page_path) ⇒ Object
24 25 26 27 28 |
# 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 |
#clear_shared ⇒ Object
30 31 32 33 34 |
# File 'lib/pagelime/cache_engine.rb', line 30 def clear_shared cache_key = static_shared_cache_key delete cache_key end |
#delete(key) ⇒ Object
46 47 48 |
# File 'lib/pagelime/cache_engine.rb', line 46 def delete(key) @config.cache.delete(key) if @config.cache end |
#fetch(key, options = {}, &block) ⇒ Object
Generic cache methods
38 39 40 41 42 43 44 |
# File 'lib/pagelime/cache_engine.rb', line 38 def fetch(key, = {}, &block) if @config.cache @config.cache.fetch(key, , &block) else yield end end |
#fetch_path(page_path, &block) ⇒ Object
CMS-specific methods
12 13 14 15 16 |
# 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, , &block) end |
#fetch_shared(&block) ⇒ Object
18 19 20 21 22 |
# File 'lib/pagelime/cache_engine.rb', line 18 def fetch_shared(&block) cache_key = static_shared_cache_key fetch(cache_key, , &block) end |