Class: SecretsManager::Cache
- Inherits:
-
Object
- Object
- SecretsManager::Cache
- Defined in:
- lib/secrets-manager.rb
Instance Method Summary collapse
- #find(path) ⇒ Object
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
- #reset ⇒ Object
- #set(path, value, ttl = 86400) ⇒ Object
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
16 17 18 |
# File 'lib/secrets-manager.rb', line 16 def initialize @_cache = Concurrent::Map.new end |
Instance Method Details
#find(path) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/secrets-manager.rb', line 29 def find(path) fetched = @_cache[path] return unless fetched return unless !fetched[:expires_at].nil? && (fetched[:expires_at]) > Time.now fetched[:value] end |
#reset ⇒ Object
20 21 22 |
# File 'lib/secrets-manager.rb', line 20 def reset @_cache = Concurrent::Map.new end |
#set(path, value, ttl = 86400) ⇒ Object
24 25 26 27 |
# File 'lib/secrets-manager.rb', line 24 def set(path, value, ttl = 86400) @_cache[path] = {expires_at: (Time.now + ttl), value: value} return self end |