module Mongoid::Cacheable
Encapsulates behavior around caching.
@since 6.0.0
Public Instance Methods
cache_key()
click to toggle source
Print out the cache key. This will append different values on the plural model name.
If new_record? - will append /new If not - will append /id-updated_at.to_s(cache_timestamp_format) Without updated_at - will append /id
This is usually called insode a cache() block
@example Returns the cache key
document.cache_key
@return [ String ] the string with or without updated_at
@since 2.4.0
# File lib/mongoid/cacheable.rb, line 32 def cache_key return "#{model_key}/new" if new_record? return "#{model_key}/#{_id}-#{updated_at.utc.to_s(cache_timestamp_format)}" if do_or_do_not(:updated_at) "#{model_key}/#{_id}" end