Class: Gitlab::Client::Cache::Config
- Inherits:
-
Struct
- Object
- Struct
- Gitlab::Client::Cache::Config
- Defined in:
- lib/gitlab/client/cache/config.rb
Instance Attribute Summary collapse
-
#after_load ⇒ Object
Returns the value of attribute after_load.
-
#before_dump ⇒ Object
Returns the value of attribute before_dump.
-
#cache_root ⇒ Object
Returns the value of attribute cache_root.
-
#compression ⇒ Object
Returns the value of attribute compression.
-
#expires_in ⇒ Object
Returns the value of attribute expires_in.
-
#scope ⇒ Object
Returns the value of attribute scope.
Class Method Summary collapse
- .build ⇒ Object
- .default_cache_root ⇒ Object
- .default_compression ⇒ Object
- .default_expires_in ⇒ Object
- .default_scope ⇒ Object
Instance Attribute Details
#after_load ⇒ Object
Returns the value of attribute after_load
4 5 6 |
# File 'lib/gitlab/client/cache/config.rb', line 4 def after_load @after_load end |
#before_dump ⇒ Object
Returns the value of attribute before_dump
4 5 6 |
# File 'lib/gitlab/client/cache/config.rb', line 4 def before_dump @before_dump end |
#cache_root ⇒ Object
Returns the value of attribute cache_root
4 5 6 |
# File 'lib/gitlab/client/cache/config.rb', line 4 def cache_root @cache_root end |
#compression ⇒ Object
Returns the value of attribute compression
4 5 6 |
# File 'lib/gitlab/client/cache/config.rb', line 4 def compression @compression end |
#expires_in ⇒ Object
Returns the value of attribute expires_in
4 5 6 |
# File 'lib/gitlab/client/cache/config.rb', line 4 def expires_in @expires_in end |
#scope ⇒ Object
Returns the value of attribute scope
4 5 6 |
# File 'lib/gitlab/client/cache/config.rb', line 4 def scope @scope end |
Class Method Details
.build ⇒ Object
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_root ⇒ Object
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_compression ⇒ Object
29 30 31 |
# File 'lib/gitlab/client/cache/config.rb', line 29 def self.default_compression "Zlib" end |
.default_expires_in ⇒ Object
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_scope ⇒ Object
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 |