Class: BellyWash::Driver::Redis
- Inherits:
-
Object
- Object
- BellyWash::Driver::Redis
- Defined in:
- lib/belly_wash/driver/redis.rb
Instance Attribute Summary collapse
-
#prefix ⇒ Object
Returns the value of attribute prefix.
Instance Method Summary collapse
- #get(key:) ⇒ Object
- #inc(key:, **values) ⇒ Object
-
#initialize(client = ::Redis.current, prefix: 'bw') ⇒ Redis
constructor
A new instance of Redis.
Constructor Details
#initialize(client = ::Redis.current, prefix: 'bw') ⇒ Redis
Returns a new instance of Redis.
10 11 12 13 |
# File 'lib/belly_wash/driver/redis.rb', line 10 def initialize(client = ::Redis.current, prefix: 'bw') @client = client @prefix = prefix end |
Instance Attribute Details
#prefix ⇒ Object
Returns the value of attribute prefix.
8 9 10 |
# File 'lib/belly_wash/driver/redis.rb', line 8 def prefix @prefix end |
Instance Method Details
#get(key:) ⇒ Object
22 23 24 25 |
# File 'lib/belly_wash/driver/redis.rb', line 22 def get(key:) pkey = [@prefix, key].join('::') @client.hgetall(pkey) end |
#inc(key:, **values) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/belly_wash/driver/redis.rb', line 15 def inc(key:, **values) pkey = [@prefix, key].join('::') values.each do |k, c| @client.hincrby(pkey, k, c) end end |