Sha256: eb757dcc7b1c2597c7bb1fc805d1337e647b62bf30223875400071cd7d5c2856
Contents?: true
Size: 661 Bytes
Versions: 11
Compression:
Stored size: 661 Bytes
Contents
module Gris module CacheKey extend ActiveSupport::Concern included do def cache_key case when new_record? fail NotImplementedError when timestamp = try(:updated_at) timestamp = timestamp.utc.to_s(:number) "#{self.class.model_name.cache_key}/#{id}-#{timestamp}" else "#{self.class.model_name.cache_key}/#{id}" end end end class_methods do def cache_key_for(id) "#{model_name.cache_key}/#{id}" end def cached_find(id) Gris.cache.fetch(cache_key_for(id)) do find(id) end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems