Class: Gcpc::Interceptors::Utils::RedisStore
- Inherits:
-
Object
- Object
- Gcpc::Interceptors::Utils::RedisStore
- Defined in:
- lib/gcpc/interceptors/utils/redis_store.rb
Instance Method Summary collapse
- #exists(key) ⇒ bool
- #get(key) ⇒ String
-
#initialize(redis:) ⇒ RedisStore
constructor
A new instance of RedisStore.
- #set(key, val, ttl: nil) ⇒ bool
Constructor Details
#initialize(redis:) ⇒ RedisStore
Returns a new instance of RedisStore.
5 6 7 |
# File 'lib/gcpc/interceptors/utils/redis_store.rb', line 5 def initialize(redis:) @redis = redis end |
Instance Method Details
#exists(key) ⇒ bool
33 34 35 |
# File 'lib/gcpc/interceptors/utils/redis_store.rb', line 33 def exists(key) @redis.exists(key) end |
#get(key) ⇒ String
12 13 14 |
# File 'lib/gcpc/interceptors/utils/redis_store.rb', line 12 def get(key) @redis.get(key) end |
#set(key, val, ttl: nil) ⇒ bool
21 22 23 24 25 26 27 28 |
# File 'lib/gcpc/interceptors/utils/redis_store.rb', line 21 def set(key, val, ttl: nil) if ttl @redis.setex(key, ttl, val) else @redis.set(key, val) end true end |