Commit 3c4554f5dce32c966a2bc375b5779e6a9d1bbd01
1 parent
6e085769
Exists in
master
and in
28 other branches
Replacing Regexp by string on expiring blocks caches
From: http://apidock.com/rails/v2.3.2/ActionController/Caching/Fragments/expire_fragment Regexp - Will remove any fragment that matches, so %r{pages/\d*/notes} might remove all notes. Make sure you don’t use anchors in the regex (^ or $) because the actual filename matched looks like ./cache/filename/path.cache. Note: Regexp expiration is only supported on caches that can iterate over all keys (unlike memcached).
Showing
2 changed files
with
5 additions
and
10 deletions
Show diff stats
app/models/recent_documents_block.rb
app/sweepers/block_sweeper.rb
... | ... | @@ -5,15 +5,14 @@ class BlockSweeper < ActiveRecord::Observer |
5 | 5 | class << self |
6 | 6 | include SweeperHelper |
7 | 7 | |
8 | - def cache_key_regex(block) | |
8 | + # Expire block's all languages cache | |
9 | + def expire_block(block) | |
9 | 10 | regex = '-[a-z]*$' |
10 | 11 | clean_ck = block.cache_key.gsub(/#{regex}/,'') |
11 | - %r{#{clean_ck+regex}} | |
12 | - end | |
13 | 12 | |
14 | - # Expire block's all languages cache | |
15 | - def expire_block(block) | |
16 | - expire_timeout_fragment(cache_key_regex(block)) | |
13 | + Noosfero.locales.keys.each do |locale| | |
14 | + expire_timeout_fragment("#{clean_ck}-#{locale}") | |
15 | + end | |
17 | 16 | end |
18 | 17 | |
19 | 18 | def expire_blocks(blocks) | ... | ... |