Class: Gitlab::Cache::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/cache/metadata.rb

Overview

Value object for cache metadata

Constant Summary collapse

VALID_BACKING_RESOURCES =
[:cpu, :database, :gitaly, :memory, :unknown].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cache_identifier: nil, feature_category: Client::DEFAULT_FEATURE_CATEGORY, backing_resource: Client::DEFAULT_BACKING_RESOURCE) ⇒ Gitlab::Cache::Metadata

Parameters:

  • cache_identifier (String) (defaults to: nil)

    defines the location of the cache definition Example: “ProtectedBranches::CacheService#fetch”

  • feature_category (Symbol) (defaults to: Client::DEFAULT_FEATURE_CATEGORY)

    name of the feature category (from config/feature_categories.yml)

  • backing_resource (Symbol) (defaults to: Client::DEFAULT_BACKING_RESOURCE)

    most affected resource by cache generation (full list: VALID_BACKING_RESOURCES)



14
15
16
17
18
19
20
21
22
# File 'lib/gitlab/cache/metadata.rb', line 14

def initialize(
  cache_identifier: nil,
  feature_category: Client::DEFAULT_FEATURE_CATEGORY,
  backing_resource: Client::DEFAULT_BACKING_RESOURCE
)
  @cache_identifier = cache_identifier
  @feature_category = fetch_feature_category!(feature_category)
  @backing_resource = fetch_backing_resource!(backing_resource)
end

Instance Attribute Details

#backing_resourceObject (readonly)

Returns the value of attribute backing_resource.



24
25
26
# File 'lib/gitlab/cache/metadata.rb', line 24

def backing_resource
  @backing_resource
end

#cache_identifierObject (readonly)

Returns the value of attribute cache_identifier.



24
25
26
# File 'lib/gitlab/cache/metadata.rb', line 24

def cache_identifier
  @cache_identifier
end

#feature_categoryObject (readonly)

Returns the value of attribute feature_category.



24
25
26
# File 'lib/gitlab/cache/metadata.rb', line 24

def feature_category
  @feature_category
end