Class: Pagelime::CacheEngine

Inherits:
Object
  • Object
show all
Defined in:
lib/pagelime/cache_engine.rb

Instance Method Summary collapse

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_sharedObject



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, options = {}, &block)
  if @config.cache
    @config.cache.fetch(key, fetch_options, &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, fetch_options, &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, fetch_options, &block)
end