Skip to content

Commit

Permalink
Merge pull request #2085 from zz9pzza/issue_4084
Browse files Browse the repository at this point in the history
Issue 4084
  • Loading branch information
elzj committed Apr 10, 2015
2 parents fc78cfd + 996da63 commit 7a519bf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/works/_work_module.html.erb
Expand Up @@ -23,7 +23,7 @@
<!-- do not cache -->
<%= byline(work, visibility: "public") %>
<% #### CACHE show/hide #### %>
<% #### CACHE show/hide ####, if you update the key edit lib/tasks/memcached.rake %>
<% cache("#{work.cache_key}-#{hide_warnings?(work) ? 'nowarn' : 'showwarn'}-#{hide_freeform?(work) ? 'nofreeform' : 'showfreeform'}-v5") do %>
<% tag_groups = work.tags.group_by { |t| t.type.to_s } %>
Expand Down
19 changes: 19 additions & 0 deletions lib/tasks/memcached.rake
@@ -0,0 +1,19 @@
namespace :memcached do

# For example
# WORKS="posted = 0" rake memcached:clear_work
#
desc "Clear memcached"
task :expire_work_blurbs => :environment do
works=ENV['WORKS'] || 'id=1'
Work.where(works).find_each do |work|
puts "Clear memcached #{work.id}"
%w( nowarn showwarn ).each do |warn|
%w( nofreeform showfreeform ).each do |freeform|
Rails.cache.delete "#{work.cache_key}-#{warn}-#{freeform}-v5"
end
end
end
end

end

0 comments on commit 7a519bf

Please sign in to comment.