Class: AwsDevUtils::Backend::Redis
- Inherits:
-
Object
- Object
- AwsDevUtils::Backend::Redis
- Defined in:
- lib/aws-dev-utils/backends/redis.rb
Instance Method Summary collapse
-
#get(key) ⇒ Object
Get the value of key, if not found, returns nil.
-
#initialize(url = 'redis://localhost:6379') ⇒ Redis
constructor
:nocov: Initialize a new redis client.
-
#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(url = 'redis://localhost:6379') ⇒ Redis
:nocov: Initialize a new redis client.
9 10 11 |
# File 'lib/aws-dev-utils/backends/redis.rb', line 9 def initialize url='redis://localhost:6379' @redis = ::Redis.new(url: url) end |
Instance Method Details
#get(key) ⇒ Object
Get the value of key, if not found, returns nil.
14 15 16 |
# File 'lib/aws-dev-utils/backends/redis.rb', line 14 def get key @redis.get key 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).
22 23 24 |
# File 'lib/aws-dev-utils/backends/redis.rb', line 22 def set key, value, exp @redis.setex key, exp, value end |