Commit d070eece9c104fb7e06532380202a506aeb62029
1 parent
b62b0d9c
Exists in
master
and in
29 other branches
Some points still need #is_cache_expired?(key)
Showing
2 changed files
with
7 additions
and
2 deletions
Show diff stats
app/controllers/public/profile_controller.rb
| @@ -23,7 +23,7 @@ class ProfileController < PublicController | @@ -23,7 +23,7 @@ class ProfileController < PublicController | ||
| 23 | 23 | ||
| 24 | def tags | 24 | def tags |
| 25 | @tags_cache_key = "tags_profile_#{profile.id.to_s}" | 25 | @tags_cache_key = "tags_profile_#{profile.id.to_s}" |
| 26 | - if is_cache_expired?(@tags_cache_key, true) | 26 | + if is_cache_expired?(@tags_cache_key) |
| 27 | @tags = profile.article_tags | 27 | @tags = profile.article_tags |
| 28 | end | 28 | end |
| 29 | end | 29 | end |
| @@ -31,7 +31,7 @@ class ProfileController < PublicController | @@ -31,7 +31,7 @@ class ProfileController < PublicController | ||
| 31 | def content_tagged | 31 | def content_tagged |
| 32 | @tag = params[:id] | 32 | @tag = params[:id] |
| 33 | @tag_cache_key = "tag_#{CGI.escape(@tag.to_s)}_#{profile.id.to_s}_page_#{params[:npage]}" | 33 | @tag_cache_key = "tag_#{CGI.escape(@tag.to_s)}_#{profile.id.to_s}_page_#{params[:npage]}" |
| 34 | - if is_cache_expired?(@tag_cache_key, true) | 34 | + if is_cache_expired?(@tag_cache_key) |
| 35 | @tagged = profile.find_tagged_with(@tag).paginate(:per_page => 20, :page => params[:npage]) | 35 | @tagged = profile.find_tagged_with(@tag).paginate(:per_page => 20, :page => params[:npage]) |
| 36 | end | 36 | end |
| 37 | end | 37 | end |
app/helpers/application_helper.rb
| @@ -1316,4 +1316,9 @@ module ApplicationHelper | @@ -1316,4 +1316,9 @@ module ApplicationHelper | ||
| 1316 | def cache_timeout(key, timeout, &block) | 1316 | def cache_timeout(key, timeout, &block) |
| 1317 | cache(key, { :expires_in => timeout }, &block) | 1317 | cache(key, { :expires_in => timeout }, &block) |
| 1318 | end | 1318 | end |
| 1319 | + | ||
| 1320 | + def is_cache_expired?(key) | ||
| 1321 | + !cache_store.fetch(ActiveSupport::Cache.expand_cache_key(key, :controller)) | ||
| 1322 | + end | ||
| 1323 | + | ||
| 1319 | end | 1324 | end |