Module: Blacklight::Document::CacheKey

Included in:
Blacklight::Document
Defined in:
app/models/concerns/blacklight/document/cache_key.rb

Overview

This module provides the cache key which can be used by rails caching to determine when to expire a particular object’s cache See apidock.com/rails/ActiveRecord/Integration/cache_key This key should be used in conjunction with additional data to determine when a document can be cached (e.g. for different view types in search results like gallery and list)

Instance Method Summary collapse

Instance Method Details

#cache_keyObject



10
11
12
13
14
15
16
17
18
19
# File 'app/models/concerns/blacklight/document/cache_key.rb', line 10

def cache_key
  if new_record?
    "#{self.class.model_name.cache_key}/new"
  elsif key? cache_version_key
    cache_version_value = self[cache_version_key]
    "#{self.class.model_name.cache_key}/#{id}-#{Array(cache_version_value).join}"
  else
    "#{self.class.model_name.cache_key}/#{id}"
  end
end

#cache_version_keyObject



21
22
23
# File 'app/models/concerns/blacklight/document/cache_key.rb', line 21

def cache_version_key
  :_version_
end