模块:Mongoid::Cacheable
Overview
封装与缓存相关的行为。
实例方法摘要折叠
-
# cache_key ⇒ string
打印出缓存键。
实例方法详细信息
# cache_key ⇒ string
打印出缓存键。 这将为复数模型名称附加不同的值。
如果 new_record? - 将追加 /new 如果没有 - 将追加 /id-updated_at.to_formatted_s(cache_timestamp_format) 没有 updated_at - 将附加 / ID
这通常在 cache() 块内调用
28 29 30 31 32 |
# File 'lib/mongoid/cacheable.rb', line 28 def cache_key return " #{ model_key } /new " if new_record? return " #{ model_key } / #{ _id } - #{ updated_at . utc . to_formatted_s ( ) } " if try(:updated_at) "#{model_key}/#{_id}" end |