Module: BlanketCachekey
- Defined in:
- lib/blanket_cachekey.rb,
lib/blanket_cachekey/engine.rb,
lib/blanket_cachekey/version.rb
Defined Under Namespace
Classes: Engine
Constant Summary collapse
- VERSION =
"0.0.1"
Class Attribute Summary collapse
-
.cache ⇒ Object
Returns the value of attribute cache.
Class Method Summary collapse
Class Attribute Details
.cache ⇒ Object
Returns the value of attribute cache.
8 9 10 |
# File 'lib/blanket_cachekey.rb', line 8 def cache @cache end |
Class Method Details
.included(model) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/blanket_cachekey.rb', line 12 def self.included(model) model.class_eval do after_save :invalidate_blanket_cachekey after_destroy :invalidate_blanket_cachekey private def invalidate_blanket_cachekey self.class.invalidate_blanket_cachekey end class << self def blanket_cachekey BlanketCachekey.cache.fetch(blanket_cachekey_name) do "#{table_name}:#{Time.now.to_i}:#{Time.now.nsec}" end end def invalidate_blanket_cachekey BlanketCachekey.cache.delete blanket_cachekey_name end private def blanket_cachekey_name "blanket_cachekey:name:#{self.table_name}" end end end end |