Module: Mongoid::Cacheable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Composable
- Defined in:
- build/mongoid-6.1/lib/mongoid/cacheable.rb
Overview
Encapsulates behaviour around caching.
Instance Method Summary collapse
-
#cache_key ⇒ String
Print out the cache key.
Instance Method Details
#cache_key ⇒ String
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
30 31 32 33 34 |
# File 'build/mongoid-6.1/lib/mongoid/cacheable.rb', line 30 def cache_key return "#{model_key}/new" if new_record? return "#{model_key}/#{id}-#{updated_at.utc.to_s()}" if do_or_do_not(:updated_at) "#{model_key}/#{id}" end |