Module: Card::Cache::ViewCache

Defined in:
lib/card/cache/view_cache.rb

Constant Summary collapse

SIZE =
500
LIMIT =

reduce cache size to SIZE if LIMIT is reached

1000
CNT_KEY =
"view_cache_cnt".freeze
FREQUENCY_KEY =
"view_cache_frequency".freeze

Class Method Summary collapse

Class Method Details

.cacheObject



10
11
12
# File 'lib/card/cache/view_cache.rb', line 10

def cache
  Card::Cache[Card::Cache::ViewCache]
end

.fetch(format, view, args, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/card/cache/view_cache.rb', line 14

def fetch format, view, args, &block
  return yield unless cacheable_view?(view, format)

  key = cache_key view, format, args
  update_cache_accounting! key

  if Card.config.view_cache == "debug"
    verbose_fetch key, &bloack
  else
    cache.fetch key, &block
  end
end

.resetObject



27
28
29
# File 'lib/card/cache/view_cache.rb', line 27

def reset
  cache.reset
end