class AwsDevUtils::Backend::Redis

Public Class Methods

new(url='redis://localhost:6379') click to toggle source

:nocov: Initialize a new redis client. @params url [String] - specify redis url connection

# File lib/aws-dev-utils/backends/redis.rb, line 9
def initialize url='redis://localhost:6379'
  @redis = ::Redis.new(url: url)
end

Public Instance Methods

get(key) click to toggle source

Get the value of key, if not found, returns nil.

# File lib/aws-dev-utils/backends/redis.rb, line 14
def get key
  @redis.get key
end
set(key, value, exp) click to toggle source

Set key to hold the value and set key to timeout after the a given expiration time(in seconds). @param key [Object] @param value [Object] @param exp [Integer] - the key-value timeout

# File lib/aws-dev-utils/backends/redis.rb, line 22
def set key, value, exp
  @redis.setex key, exp, value
end