ref: master
app/sweepers/block_sweeper.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
class BlockSweeper < ActiveRecord::Observer observe :block class << self include SweeperHelper # Expire block's all languages cache def expire_block(block) return if !block.environment regex = '-[a-z]*$' clean_ck = block.cache_key.gsub(/#{regex}/,'') block.environment.locales.keys.each do |locale| expire_timeout_fragment("#{clean_ck}-#{locale}") end end def expire_blocks(blocks) blocks.each { |block| expire_block(block) } end end def after_save(block) self.class.expire_block(block) end end |