Module: CachEmAll::ActiveRecordRelationExt

Extended by:
ActiveSupport::Concern
Defined in:
lib/cach_em_all/core_ext/active_record_relation_ext.rb

Instance Method Summary collapse

Instance Method Details

#cache_keyObject



4
5
6
7
8
9
10
# File 'lib/cach_em_all/core_ext/active_record_relation_ext.rb', line 4

def cache_key
  ar_count        = count
  max_updated_at  = maximum(:updated_at).try(:utc).try :to_s, :number
  name            = self.name.tableize
  prefix          = Digest::SHA256.hexdigest to_sql.to_s
  [name, [prefix, ar_count, max_updated_at].join('-')].join '/'
end