Class: Gitlab::Client::Cache::Config

Inherits:
Struct
  • Object
show all
Defined in:
lib/gitlab/client/cache/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#after_loadObject

Returns the value of attribute after_load

Returns:

  • (Object)

    the current value of after_load



4
5
6
# File 'lib/gitlab/client/cache/config.rb', line 4

def after_load
  @after_load
end

#before_dumpObject

Returns the value of attribute before_dump

Returns:

  • (Object)

    the current value of before_dump



4
5
6
# File 'lib/gitlab/client/cache/config.rb', line 4

def before_dump
  @before_dump
end

#cache_rootObject

Returns the value of attribute cache_root

Returns:

  • (Object)

    the current value of cache_root



4
5
6
# File 'lib/gitlab/client/cache/config.rb', line 4

def cache_root
  @cache_root
end

#compressionObject

Returns the value of attribute compression

Returns:

  • (Object)

    the current value of compression



4
5
6
# File 'lib/gitlab/client/cache/config.rb', line 4

def compression
  @compression
end

#expires_inObject

Returns the value of attribute expires_in

Returns:

  • (Object)

    the current value of expires_in



4
5
6
# File 'lib/gitlab/client/cache/config.rb', line 4

def expires_in
  @expires_in
end

#scopeObject

Returns the value of attribute scope

Returns:

  • (Object)

    the current value of scope



4
5
6
# File 'lib/gitlab/client/cache/config.rb', line 4

def scope
  @scope
end

Class Method Details

.buildObject



5
6
7
8
9
10
11
12
# File 'lib/gitlab/client/cache/config.rb', line 5

def self.build
  new(
    cache_root: default_cache_root,
    scope: default_scope,
    compression: default_compression,
    expires_in: default_expires_in
  )
end

.default_cache_rootObject



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

def self.default_cache_root
  root = ENV.fetch("GITLAB_CLIENT_CACHE_ROOT", nil)
  root ||= if ENV.key?("XDG_CACHE_HOME")
             File.join(ENV.fetch("XDG_CACHE_HOME"), Process.uid.to_s)
           else
             File.join(File.realpath(Dir.home), ".cache")
           end

  File.join(root, "gitlab-cache")
end

.default_compressionObject



29
30
31
# File 'lib/gitlab/client/cache/config.rb', line 29

def self.default_compression
  "Zlib"
end

.default_expires_inObject



33
34
35
36
37
38
# File 'lib/gitlab/client/cache/config.rb', line 33

def self.default_expires_in
  value = ENV.fetch("GITLAB_CLIENT_CACHE_EXPIRES_IN_SECONDS", nil)
  day = 24 * 60 * 60

  Integer(value || day)
end

.default_scopeObject



25
26
27
# File 'lib/gitlab/client/cache/config.rb', line 25

def self.default_scope
  ENV.fetch("GITLAB_CLIENT_CACHE_SCOPE", File.basename($PROGRAM_NAME))
end