Class: MarkingStore

Inherits:
ActionController::Caching::Fragments::MemoryStore
  • Object
show all
Defined in:
lib/marking_store.rb

Defined Under Namespace

Classes: AccessMark

Constant Summary collapse

EACH_NTH_REQUEST =
20
TTL =
20.days

Instance Method Summary collapse

Constructor Details

#initializeMarkingStore

Returns a new instance of MarkingStore.



20
21
22
23
# File 'lib/marking_store.rb', line 20

def initialize
  @at_request = 0
  @marks = []
end

Instance Method Details

#read_fragment(key, value, options = nil) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/marking_store.rb', line 30

def read_fragment(key, value, options = nil)
  @at_request += 1
  return nil unless @cache[key]
  
  @marks.find{|m| m.key == key }.update
  run_gc if (@at_request % EACH_NTH_REQUEST)
  @accessed[key]
end

#write_fragment(key, value, options = nil) ⇒ Object



25
26
27
28
# File 'lib/marking_store.rb', line 25

def write_fragment(key, value, options = nil)
  @marks << AccessMark.new(key)
  @cache[key] = value
end