Module: CloudConfig::Cache::ClassMethods
- Defined in:
- lib/cloud-config/cache.rb
Overview
Class methods for CloudConfig::Cache
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
- #Cache client instance(clientinstance) ⇒ Object readonly
Instance Method Summary collapse
-
#cache_client(client) ⇒ Object
Configure the cache client.
-
#with_cache(key, options = {}) { ... } ⇒ Object
Fetch the value of the key from the cache, if the key exists in the cache.
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
15 16 17 |
# File 'lib/cloud-config/cache.rb', line 15 def cache @cache end |
#Cache client instance(clientinstance) ⇒ Object (readonly)
15 |
# File 'lib/cloud-config/cache.rb', line 15 attr_reader :cache |
Instance Method Details
#cache_client(client) ⇒ Object
Configure the cache client
20 21 22 |
# File 'lib/cloud-config/cache.rb', line 20 def cache_client(client) @cache = client end |
#with_cache(key, options = {}) { ... } ⇒ Object
Fetch the value of the key from the cache, if the key exists in the cache
32 33 34 35 36 37 38 39 40 |
# File 'lib/cloud-config/cache.rb', line 32 def with_cache(key, = {}) return cache.get(key) if ![:reset_cache] && cache&.key?(key) value = yield cache&.set(key, value, ) value end |