Sha256: 580338df8854582ae1cdf5843e448927bfd03c0d5a55ef0f941ae3dfcda5fe58
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
module OpenConferenceWare # = CacheWatcher # # Watches for changes in models and expires the cache. class CacheWatcher < ActiveRecord::Observer # Watch for changes in these classes: observe \ Comment, Event, Proposal, Room, ScheduleItem, SessionType, Snippet, Track, User, UserFavorite # Expire the cache def self.expire(*args) Rails.logger.info("CacheWatcher: expiring cache") case Rails.cache.class.name when "ActiveSupport::Cache::MemCacheStore" Rails.cache.instance_variable_get(:@data).flush_all when "ActiveSupport::Cache::FileStore", "ActiveSupport::Cache::MemoryStore" Rails.cache.delete_matched(//) rescue nil else raise NotImplementedError, "Don't know how to expire cache: #{Rails.cache.class.name}" end end def expire(*args) self.class.expire(*args) end # Expire the cache when these triggers are called on a record alias_method :after_save, :expire alias_method :after_destroy, :expire alias_method :after_rollback, :expire end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
open_conference_ware-1.0.0.pre4 | app/observers/open_conference_ware/cache_watcher.rb |
open_conference_ware-1.0.0.pre3 | app/observers/open_conference_ware/cache_watcher.rb |