Module: CatchCache::Flush::ClassMethods
- Defined in:
- lib/catch_cache/flush.rb
Instance Method Summary collapse
-
#cache_id(*args) ⇒ Object
key_callbacks is hash that stores the a redis key with the proc value that evaluates to a unique id associated with that class.
Instance Method Details
#cache_id(*args) ⇒ Object
key_callbacks is hash that stores the a redis key with the proc value that evaluates to a unique id associated with that class. For example: ‘central_page_loan_plans` key defines the cache for the loading of loan plans index page.
An example of a redis key is “central_page_loan_plans_<uniq_id>”
Sample args for the cache_id are: cache_id :central_page_loan_plans, after_commit: { flush_cache!: -> { loan_plan.id } } cache_id :central_page_loan_plans, after_commit: :flush_all!
58 59 60 61 62 63 64 65 |
# File 'lib/catch_cache/flush.rb', line 58 def cache_id(*args) = args.last if args.last.is_a?(Hash) value_args = .values.first proc_value = value_args.is_a?(Hash) ? value_args[:flush_cache!] : value_args key_callbacks["#{args.first}__#{self.name.underscore}".to_sym] = proc_value register_callbacks_for() if .present? end |