Class: AtomicCache::DefaultConfig
- Inherits:
-
Object
- Object
- AtomicCache::DefaultConfig
- Includes:
- Singleton
- Defined in:
- lib/atomic_cache/default_config.rb
Constant Summary collapse
- CONFIG_MUTEX =
Mutex.new
- FLOAT_TIME_FORMATTER =
Proc.new { |time| time.to_f }
- TIMESTAMP_SEC_FORMATTER =
Proc.new { |time| time.to_i }
- TIMESTAMP_MS_FORMATTER =
Proc.new { |time| (time.to_f * 1000).to_i }
- ISO8601_FORMATTER =
Proc.new { |time| time.iso8601 }
- DEFAULT_TIME_FORMATTER =
FLOAT_TIME_FORMATTER- DEFAULT_SEPARATOR =
':'
Instance Attribute Summary collapse
-
#cache_storage ⇒ Object
storage adapter instance for cached values.
-
#default_options ⇒ Object
- optional
-
config.
-
#key_storage ⇒ Object
- required
-
config.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#metrics ⇒ Object
Returns the value of attribute metrics.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#separator ⇒ Object
Returns the value of attribute separator.
-
#timestamp_formatter ⇒ Object
Returns the value of attribute timestamp_formatter.
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Object
Quickly configure config singleton instance.
-
.reset ⇒ Object
Change all configured values back to default.
Instance Method Summary collapse
-
#initialize ⇒ DefaultConfig
constructor
A new instance of DefaultConfig.
-
#reset ⇒ Object
Change all configured values back to default.
Constructor Details
#initialize ⇒ DefaultConfig
Returns a new instance of DefaultConfig.
30 31 32 |
# File 'lib/atomic_cache/default_config.rb', line 30 def initialize reset end |
Instance Attribute Details
#cache_storage ⇒ Object
storage adapter instance for cached values
20 21 22 |
# File 'lib/atomic_cache/default_config.rb', line 20 def cache_storage @cache_storage end |
#default_options ⇒ Object
- optional
-
config
23 24 25 |
# File 'lib/atomic_cache/default_config.rb', line 23 def end |
#key_storage ⇒ Object
- required
-
config
19 20 21 |
# File 'lib/atomic_cache/default_config.rb', line 19 def key_storage @key_storage end |
#logger ⇒ Object
Returns the value of attribute logger.
25 26 27 |
# File 'lib/atomic_cache/default_config.rb', line 25 def logger @logger end |
#metrics ⇒ Object
Returns the value of attribute metrics.
26 27 28 |
# File 'lib/atomic_cache/default_config.rb', line 26 def metrics @metrics end |
#namespace ⇒ Object
Returns the value of attribute namespace.
24 25 26 |
# File 'lib/atomic_cache/default_config.rb', line 24 def namespace @namespace end |
#separator ⇒ Object
Returns the value of attribute separator.
28 29 30 |
# File 'lib/atomic_cache/default_config.rb', line 28 def separator @separator end |
#timestamp_formatter ⇒ Object
Returns the value of attribute timestamp_formatter.
27 28 29 |
# File 'lib/atomic_cache/default_config.rb', line 27 def end |
Class Method Details
.configure {|config| ... } ⇒ Object
Quickly configure config singleton instance
53 54 55 56 57 58 59 60 |
# File 'lib/atomic_cache/default_config.rb', line 53 def self.configure if block_given? manager = self.instance CONFIG_MUTEX.synchronize do yield(manager) end end end |
.reset ⇒ Object
Change all configured values back to default
46 47 48 |
# File 'lib/atomic_cache/default_config.rb', line 46 def self.reset self.instance.reset end |
Instance Method Details
#reset ⇒ Object
Change all configured values back to default
35 36 37 38 39 40 41 42 43 |
# File 'lib/atomic_cache/default_config.rb', line 35 def reset @cache_client = nil = {} @namespace = nil @logger = nil @metrics = nil = DEFAULT_TIME_FORMATTER @separator = DEFAULT_SEPARATOR end |