Class: AwsDevUtils::Backend::Memory
- Inherits:
-
Object
- Object
- AwsDevUtils::Backend::Memory
- Defined in:
- lib/aws-dev-utils/backends/memory.rb
Instance Method Summary collapse
-
#get(key) ⇒ Object
Get the value of key, if not found, returns nil.
-
#initialize ⇒ Memory
constructor
A new instance of Memory.
-
#set(key, value, exp) ⇒ Object
Set key to hold the value and set key to timeout after the a given expiration time(in seconds).
Constructor Details
#initialize ⇒ Memory
Returns a new instance of Memory.
5 6 7 |
# File 'lib/aws-dev-utils/backends/memory.rb', line 5 def initialize @hash = {} end |
Instance Method Details
#get(key) ⇒ Object
Get the value of key, if not found, returns nil.
10 11 12 13 |
# File 'lib/aws-dev-utils/backends/memory.rb', line 10 def get key clean_cache! @hash[key][1] end |
#set(key, value, exp) ⇒ Object
Set key to hold the value and set key to timeout after the a given expiration time(in seconds).
19 20 21 22 |
# File 'lib/aws-dev-utils/backends/memory.rb', line 19 def set key, value, exp clean_cache! @hash[key] = [Time.now + exp, value] end |