Class: Chip::RedisClient
- Inherits:
-
Object
- Object
- Chip::RedisClient
- Defined in:
- lib/chip/redis_client.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#redis_namespace ⇒ Object
readonly
Returns the value of attribute redis_namespace.
Class Method Summary collapse
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(key) ⇒ RedisClient
constructor
A new instance of RedisClient.
- #namespace ⇒ Object
- #save(token:) ⇒ Object
- #ttl ⇒ Object
Constructor Details
#initialize(key) ⇒ RedisClient
Returns a new instance of RedisClient.
11 12 13 14 |
# File 'lib/chip/redis_client.rb', line 11 def initialize(key) @redis_namespace = Redis::Namespace.new(namespace, redis: $redis) @key = key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/chip/redis_client.rb', line 5 def key @key end |
#redis_namespace ⇒ Object (readonly)
Returns the value of attribute redis_namespace.
5 6 7 |
# File 'lib/chip/redis_client.rb', line 5 def redis_namespace @redis_namespace end |
Class Method Details
.build(key) ⇒ Object
7 8 9 |
# File 'lib/chip/redis_client.rb', line 7 def self.build(key) new(key) end |
Instance Method Details
#get ⇒ Object
16 17 18 |
# File 'lib/chip/redis_client.rb', line 16 def get redis_namespace.get(key) end |
#namespace ⇒ Object
28 29 30 |
# File 'lib/chip/redis_client.rb', line 28 def namespace @namespace ||= REDIS_CONFIG[:chip][:namespace] end |
#save(token:) ⇒ Object
20 21 22 |
# File 'lib/chip/redis_client.rb', line 20 def save(token:) redis_namespace.set(key, token, ex: ttl) end |
#ttl ⇒ Object
24 25 26 |
# File 'lib/chip/redis_client.rb', line 24 def ttl @ttl ||= REDIS_CONFIG[:chip][:each_ttl] end |