Module: CacheUtils::Model
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/cache_utils/model.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#custom_cache_key ⇒ Object
15 16 17 |
# File 'lib/cache_utils/model.rb', line 15 def custom_cache_key self.class.to_s.underscore.pluralize + "/#{id}" end |
#purge_cache ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cache_utils/model.rb', line 19 def purge_cache class_keys = self.class.cache_key class_keys += extra_class_key if respond_to?(:extra_class_key) redisw = $redisw || $redis redisr = $redisr || $redis keys = (redisr.scan_each(match: custom_cache_key + '*').to_a + redisr.scan_each(match: class_keys + '*').to_a) unless keys.empty? redisw.del(*keys) Appsignal.increment_counter('cache_purge', 1) if defined?(Appsignal) end end |