Module: LatestTimestampCacheKey

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/latest_timestamp_cache_key.rb

Overview

Extends ActiveRecord::Relation to provide a method for generating cache keys based on the latest updated_at timestamp of the relation.

Example:

user.books.latest_timestamp_cache_key
=> "20250217143213"

# Can be used in cache keys:
cache_key = "books:#{user.books.latest_timestamp_cache_key}"
Rails.cache.fetch(cache_key) do
  # ... expensive operation
end