Skip to content

Commit

Permalink
add worklog sweeper
Browse files Browse the repository at this point in the history
  • Loading branch information
liufengyun committed Jan 17, 2012
1 parent 5bad300 commit fd2e000
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/tasks_controller.rb
Expand Up @@ -10,6 +10,7 @@ class TasksController < ApplicationController


cache_sweeper :tag_sweeper, :only =>[:create, :update] cache_sweeper :tag_sweeper, :only =>[:create, :update]
cache_sweeper :task_sweeper cache_sweeper :task_sweeper
cache_sweeper :work_log_sweeper


def index def index
#TODO: Code smell, we should be dealing only with collections here #TODO: Code smell, we should be dealing only with collections here
Expand Down
15 changes: 15 additions & 0 deletions app/sweepers/work_log_sweeper.rb
@@ -0,0 +1,15 @@
class WorkLogSweeper < ActionController::Caching::Sweeper
observe WorkLog

def after_update(log)
expire_fragment(["task_json", log.task])
end

def after_create(log)
expire_fragment(["task_json", log.task])
end

def after_destroy(log)
expire_fragment(["task_json", log.task])
end
end

0 comments on commit fd2e000

Please sign in to comment.