Sha256: 55327ffec19f47280f3d9c23111cfcb3b4fb22dbc88abeb81a7612065fcdde56

Contents?: true

Size: 823 Bytes

Versions: 31

Compression:

Stored size: 823 Bytes

Contents

# frozen_string_literal: true
# This module provides the cache key which can be used by rails
# caching to determine when to expire a particular object's cache
# See http://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)
module Blacklight::Document::CacheKey
  def cache_key
    if new_record?
      "#{self.class.model_name.cache_key}/new"
    elsif self.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

  def cache_version_key
    :_version_
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
blacklight-6.25.0 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.24.0 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.23.0 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.22.0 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.21.0 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.20.0 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.19.2 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.19.1 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.19.0 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.18.0 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.17.0 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.16.0 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.15.0 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.14.1 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.14.0 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.13.0 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.12.0 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.11.2 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.11.1 app/models/concerns/blacklight/document/cache_key.rb
blacklight-6.11.0 app/models/concerns/blacklight/document/cache_key.rb