Sha256: 751bb30c292b88d3d40041eb5128c059d14599941a767d07abc7813ae296feb8

Contents?: true

Size: 627 Bytes

Versions: 1

Compression:

Stored size: 627 Bytes

Contents

class ThreadSweeper < ActionController::Caching::Sweeper
  observe Discussion::ThreadRead

  def after_save(thread_read)
    expire_cache_for(thread_read) if thread_read.read_changed?
  end

  def after_create(thread_read)
    expire_cache_for(thread_read)
  end

  def after_destroy(thread_read)
    expire_cache_for(thread_read)
  end

  private
  def expire_cache_for(thread_read)
    Rails.logger.debug "deleting cache for :: #{thread_read.user_id}"
    Rails.logger.debug "================================================================="
    Rails.cache.delete("total_unread_thread_by_#{thread_read.user_id}")
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
discussion-0.0.1 app/models/thread_sweeper.rb