Module: ActiveRecordTweaks::Integration::ClassMethods
- Defined in:
- lib/active_record_tweaks/integration.rb
Instance Method Summary collapse
-
#cache_key(*args) ⇒ Object
Returns a cache key for the ActiveRecord class based based on count and maximum value of update timestamp columns (e.g. Cookie based caching with expiration).
-
#cache_key_without_timestamp ⇒ Object
Returns a cache key for the ActiveRecord class based based on count only.
Instance Method Details
#cache_key(*args) ⇒ Object
Returns a cache key for the ActiveRecord class based based on count and maximum value of update timestamp columns (e.g. Cookie based caching with expiration)
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/active_record_tweaks/integration.rb', line 80 def cache_key(*args) = args.empty? ? [:updated_at] : args if ( = ()) = .utc.to_s() "#{model_name.cache_key}/all/#{count}-#{}" else end end |
#cache_key_without_timestamp ⇒ Object
Returns a cache key for the ActiveRecord class based based on count only
Product.cache_key # => "products/all/0" (empty, has updated timestamp columns or not)
Product.cache_key # => "products/all/1" (not empty but has no updated timestamp columns)
Person.cache_key # => "people/all/1" (not empty and has updated timestamp columns)
99 100 101 |
# File 'lib/active_record_tweaks/integration.rb', line 99 def "#{model_name.cache_key}/all/#{count}" end |