Module: Cacheable::Expiry
- Defined in:
- lib/cacheable/expiry.rb
Instance Method Summary collapse
- #expire_all_attribute_cache ⇒ Object
- #expire_association_cache(name) ⇒ Object
- #expire_attribute_cache ⇒ Object
- #expire_class_method_cache ⇒ Object
- #expire_key_cache ⇒ Object
- #expire_method_cache ⇒ Object
- #expire_model_cache ⇒ Object
Instance Method Details
#expire_all_attribute_cache ⇒ Object
28 29 30 31 32 33 |
# File 'lib/cacheable/expiry.rb', line 28 def expire_all_attribute_cache self.class.cached_indices.each do |attribute, values| value = self.send(attribute) Rails.cache.delete self.class.all_attribute_cache_key(attribute, value) end end |
#expire_association_cache(name) ⇒ Object
49 50 51 |
# File 'lib/cacheable/expiry.rb', line 49 def expire_association_cache(name) Rails.cache.delete have_association_cache_key(name) end |
#expire_attribute_cache ⇒ Object
21 22 23 24 25 26 |
# File 'lib/cacheable/expiry.rb', line 21 def expire_attribute_cache self.class.cached_indices.each do |attribute, values| value = self.send(attribute) Rails.cache.delete self.class.attribute_cache_key(attribute, value) end end |
#expire_class_method_cache ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/cacheable/expiry.rb', line 41 def expire_class_method_cache self.class.cached_class_methods.each do |meth, args| args.each do |arg| Rails.cache.delete self.class.class_method_cache_key(meth, arg) end end end |
#expire_key_cache ⇒ Object
17 18 19 |
# File 'lib/cacheable/expiry.rb', line 17 def expire_key_cache Rails.cache.delete model_cache_key end |
#expire_method_cache ⇒ Object
35 36 37 38 39 |
# File 'lib/cacheable/expiry.rb', line 35 def expire_method_cache self.class.cached_methods.each do |meth| Rails.cache.delete method_cache_key(meth) end end |
#expire_model_cache ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/cacheable/expiry.rb', line 3 def expire_model_cache expire_key_cache if self.class.cached_key expire_attribute_cache if self.class.cached_indices.present? expire_all_attribute_cache if self.class.cached_indices.present? expire_method_cache if self.class.cached_methods.present? expire_class_method_cache if self.class.cached_class_methods.present? if self.class.cached_associations.present? self.class.cached_associations.each do |assoc| expire_association_cache(assoc) end end end |