Class: Puppet::ResourceApi::ProviderGetCache
- Inherits:
-
Object
- Object
- Puppet::ResourceApi::ProviderGetCache
- Defined in:
- lib/puppet/resource_api/provider_get_cache.rb
Overview
This class provides a simple caching mechanism to support minimizing get() calls into a provider.
Instance Method Summary collapse
- #add(key, value) ⇒ Object
- #all ⇒ Object
- #cached_all ⇒ Object
- #cached_all? ⇒ Boolean
- #clear ⇒ Object
- #get(key) ⇒ Object
-
#initialize ⇒ ProviderGetCache
constructor
A new instance of ProviderGetCache.
Constructor Details
#initialize ⇒ ProviderGetCache
Returns a new instance of ProviderGetCache.
11 12 13 |
# File 'lib/puppet/resource_api/provider_get_cache.rb', line 11 def initialize clear end |
Instance Method Details
#add(key, value) ⇒ Object
26 27 28 |
# File 'lib/puppet/resource_api/provider_get_cache.rb', line 26 def add(key, value) @cache[key] = value end |
#all ⇒ Object
20 21 22 23 24 |
# File 'lib/puppet/resource_api/provider_get_cache.rb', line 20 def all raise 'all method called, but cached_all not called' unless @cached_all @cache.values end |
#cached_all ⇒ Object
34 35 36 |
# File 'lib/puppet/resource_api/provider_get_cache.rb', line 34 def cached_all @cached_all = true end |
#cached_all? ⇒ Boolean
38 39 40 |
# File 'lib/puppet/resource_api/provider_get_cache.rb', line 38 def cached_all? @cached_all end |
#clear ⇒ Object
15 16 17 18 |
# File 'lib/puppet/resource_api/provider_get_cache.rb', line 15 def clear @cache = {} @cached_all = false end |
#get(key) ⇒ Object
30 31 32 |
# File 'lib/puppet/resource_api/provider_get_cache.rb', line 30 def get(key) @cache[key] end |