Class: ActiveRecord::Relation

Inherits:
Object
  • Object
show all
Includes:
PgCacheKey
Defined in:
lib/pg_cache_key.rb

Overview

Active Record Relation

Constant Summary

Constants included from PgCacheKey

PgCacheKey::VERSION

Instance Method Summary collapse

Methods included from PgCacheKey

#cache_key_raw_sql

Instance Method Details

#cache_key(timestamp_column = :updated_at) ⇒ Object



32
33
34
35
36
37
# File 'lib/pg_cache_key.rb', line 32

def cache_key(timestamp_column = :updated_at)
  return "#{self.class.to_s.underscore}/blank" if to_sql.blank?
  @cache_keys ||= {}
  @cache_keys[timestamp_column] ||= connection.execute( cache_key_raw_sql(timestamp_column) )[0]['cache_key']
  @cache_keys[timestamp_column] ||= collection_cache_key
end