Commit d4d4cab12654c02591ec35c647d6b0a2e250c0a8
Committed by
Antonio Terceiro
1 parent
2fd72e94
Exists in
master
and in
22 other branches
ActionItem1205: fixing cache_timeout
* making profile index expire
Showing
5 changed files
with
13 additions
and
4 deletions
Show diff stats
app/helpers/sweeper_helper.rb
| @@ -43,4 +43,7 @@ module SweeperHelper | @@ -43,4 +43,7 @@ module SweeperHelper | ||
| 43 | blocks.map(&:cache_keys).each{|ck|expire_timeout_fragment(ck)} | 43 | blocks.map(&:cache_keys).each{|ck|expire_timeout_fragment(ck)} |
| 44 | end | 44 | end |
| 45 | 45 | ||
| 46 | + def expire_profile_index(profile) | ||
| 47 | + expire_timeout_fragment(profile.relationships_cache_key) | ||
| 48 | + end | ||
| 46 | end | 49 | end |
app/models/person.rb
| @@ -275,4 +275,8 @@ class Person < Profile | @@ -275,4 +275,8 @@ class Person < Profile | ||
| 275 | page = params[:npage] || '1' | 275 | page = params[:npage] || '1' |
| 276 | identifier + '-manage-friends-page-' + page | 276 | identifier + '-manage-friends-page-' + page |
| 277 | end | 277 | end |
| 278 | + | ||
| 279 | + def relationships_cache_key | ||
| 280 | + identifier + '-profile-relationships' | ||
| 281 | + end | ||
| 278 | end | 282 | end |
app/sweepers/profile_sweeper.rb
| @@ -17,8 +17,11 @@ protected | @@ -17,8 +17,11 @@ protected | ||
| 17 | profile.members.each do |member| | 17 | profile.members.each do |member| |
| 18 | expire_communities(member) if profile.community? | 18 | expire_communities(member) if profile.community? |
| 19 | expire_enterprises(member) if profile.enterprise? | 19 | expire_enterprises(member) if profile.enterprise? |
| 20 | + expire_profile_index(member) if profile.enterprise? | ||
| 20 | end | 21 | end |
| 21 | 22 | ||
| 23 | + expire_profile_index(profile) if profile.person? | ||
| 24 | + | ||
| 22 | profile.blocks.each do |block| | 25 | profile.blocks.each do |block| |
| 23 | expire_timeout_fragment(block.cache_keys) | 26 | expire_timeout_fragment(block.cache_keys) |
| 24 | end | 27 | end |
app/views/profile/_person.rhtml
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | <%= display_field(_('e-Mail:'), profile, :email, true) { |email| link_to_email(email) } %> | 16 | <%= display_field(_('e-Mail:'), profile, :email, true) { |email| link_to_email(email) } %> |
| 17 | <% end %> | 17 | <% end %> |
| 18 | 18 | ||
| 19 | -<% cache_timeout(profile.identifier + '-profile-relationships', 4.hours.from_now) do %> | 19 | +<% cache_timeout(profile.relationships_cache_key, 4.hours.from_now) do %> |
| 20 | <% if !(profile.organization.blank? && profile.organization_website.blank?) && (profile.active_fields.include?('organization') || profile.active_fields.include?('organization_website')) %> | 20 | <% if !(profile.organization.blank? && profile.organization_website.blank?) && (profile.active_fields.include?('organization') || profile.active_fields.include?('organization_website')) %> |
| 21 | <tr> | 21 | <tr> |
| 22 | <th colspan='2'><%= _('Work')%></th> | 22 | <th colspan='2'><%= _('Work')%></th> |
vendor/plugins/timed_cached_fragment/lib/timed_cache_fragment.rb
| @@ -3,14 +3,13 @@ module ActionController | @@ -3,14 +3,13 @@ module ActionController | ||
| 3 | module Cache | 3 | module Cache |
| 4 | module TimedCache | 4 | module TimedCache |
| 5 | #handles standard ERB fragments used in RHTML | 5 | #handles standard ERB fragments used in RHTML |
| 6 | - def cache_timeout(name={}, expire = 10.minutes.from_now, &block) | 6 | + def cache_timeout(key={}, expire = 10.minutes.from_now, &block) |
| 7 | unless perform_caching then block.call; return end | 7 | unless perform_caching then block.call; return end |
| 8 | - key = fragment_cache_key(name) | ||
| 9 | if is_cache_expired?(key,true) | 8 | if is_cache_expired?(key,true) |
| 10 | expire_timeout_fragment(key) | 9 | expire_timeout_fragment(key) |
| 11 | set_timeout(key, expire) | 10 | set_timeout(key, expire) |
| 12 | end | 11 | end |
| 13 | - cache_erb_fragment(block,name) | 12 | + cache_erb_fragment(block,key) |
| 14 | end | 13 | end |
| 15 | #handles the expiration of timeout fragment | 14 | #handles the expiration of timeout fragment |
| 16 | def expire_timeout_fragment(key) | 15 | def expire_timeout_fragment(key) |