Class: CacheBuster

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/cache_buster.rb

Constant Summary collapse

DEFAULT_TIMEOUT =
1.day

Class Method Summary collapse

Class Method Details

.bust_busterObject



19
20
21
22
23
24
25
26
# File 'app/models/cache_buster.rb', line 19

def self.bust_buster
  if self.first.nil?
     self.new.save
  else
    self.first.save
  end
  self.first
end

.busterObject



7
8
9
10
11
12
13
14
15
16
17
# File 'app/models/cache_buster.rb', line 7

def self.buster
  self.there_can_be_only_one

  if self.first.updated_at.to_i < Time.now.to_i-self.timeout
    buster = self.bust_buster
  else
    buster = self.last
  end

  "?#{buster.updated_at.to_i}"
end

.timeoutObject



28
29
30
# File 'app/models/cache_buster.rb', line 28

def self.timeout
  (Radiant::Config['cache_buster.timeout'] ? Radiant::Config['cache_buster.timeout'].to_i : DEFAULT_TIMEOUT).to_i
end