Class: CacheExpiration

Inherits:
ActiveRecord::Observer
  • Object
show all
Defined in:
app/observers/cache_expiration.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.expire_view_cacheObject


16
17
18
19
20
21
22
23
24
25
# File 'app/observers/cache_expiration.rb', line 16

def self.expire_view_cache
  I18n.available_locales.each do |locale|
    [[:home, :index], [:highlights], [:jobs]].each do |segment|
      key = [:views, Whitelabel[:label_id], locale]
      key = key.concat(segment).join("/")
      Rails.logger.info "expire fragment '#{key}'"
      Rails.cache.delete key
    end
  end
end

Instance Method Details

#after_create(entitiy) ⇒ Object


4
5
6
# File 'app/observers/cache_expiration.rb', line 4

def after_create(entitiy)
  self.class.expire_view_cache
end

#after_destroy(entitiy) ⇒ Object


12
13
14
# File 'app/observers/cache_expiration.rb', line 12

def after_destroy(entitiy)
  self.class.expire_view_cache
end

#after_update(entitiy) ⇒ Object


8
9
10
# File 'app/observers/cache_expiration.rb', line 8

def after_update(entitiy)
  self.class.expire_view_cache
end