Module: Stale::Fragments

Included in:
Controller, View
Defined in:
lib/stale/fragments.rb

Instance Method Summary collapse

Instance Method Details

#read_stale_fragment(key_array) ⇒ Object



3
4
5
6
# File 'lib/stale/fragments.rb', line 3

def read_stale_fragment(key_array)
  key_string = Stale.interface.key_as_string(key_array)
  Stale.cache.get(key_string)
end

#stale_fragment_exist?(key_array) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/stale/fragments.rb', line 15

def stale_fragment_exist?(key_array)
  !!read_stale_fragment(key_array)
end

#write_stale_fragment(key_array, value, ttl = nil) ⇒ Object



8
9
10
11
12
13
# File 'lib/stale/fragments.rb', line 8

def write_stale_fragment(key_array, value, ttl = nil)
  ttl ||= Stale.configuration[:expiration_time]

  key_string = Stale.interface.key_as_string(key_array)
  Stale.cache.set(key_string, value, ttl)
end