Class: LionAttr::InternalRedis
- Inherits:
-
Object
- Object
- LionAttr::InternalRedis
- Defined in:
- lib/lion_attr/internal_redis.rb
Overview
Instance Method Summary collapse
- #del(key) ⇒ Object
- #exists(key) ⇒ Object
- #get(key) ⇒ Object
- #incrby(key, increment) ⇒ Object
- #incrbyfloat(key, increment) ⇒ Object
-
#initialize(hash_name) ⇒ InternalRedis
constructor
A new instance of InternalRedis.
- #mget(keys) ⇒ Object
- #redis ⇒ Object
- #set(key, value) ⇒ Object
- #setnx(key, value) ⇒ Object
Constructor Details
#initialize(hash_name) ⇒ InternalRedis
Returns a new instance of InternalRedis.
5 6 7 |
# File 'lib/lion_attr/internal_redis.rb', line 5 def initialize(hash_name) @hash_name = hash_name end |
Instance Method Details
#del(key) ⇒ Object
21 22 23 |
# File 'lib/lion_attr/internal_redis.rb', line 21 def del(key) redis.with { |c| c.hdel @hash_name, key } end |
#exists(key) ⇒ Object
17 18 19 |
# File 'lib/lion_attr/internal_redis.rb', line 17 def exists(key) redis.with { |c| c.hexists @hash_name, key } end |
#get(key) ⇒ Object
9 10 11 |
# File 'lib/lion_attr/internal_redis.rb', line 9 def get(key) redis.with { |c| c.hget @hash_name, key } end |
#incrby(key, increment) ⇒ Object
30 31 32 |
# File 'lib/lion_attr/internal_redis.rb', line 30 def incrby(key, increment) redis.with { |c| c.hincrby @hash_name, key, increment } end |
#incrbyfloat(key, increment) ⇒ Object
34 35 36 |
# File 'lib/lion_attr/internal_redis.rb', line 34 def incrbyfloat(key, increment) redis.with { |c| c.hincrbyfloat @hash_name, key, increment } end |
#mget(keys) ⇒ Object
38 39 40 |
# File 'lib/lion_attr/internal_redis.rb', line 38 def mget(keys) redis.with { |c| c.hmget @hash_name, keys } end |
#redis ⇒ Object
42 43 44 |
# File 'lib/lion_attr/internal_redis.rb', line 42 def redis RedisPool.instance end |
#set(key, value) ⇒ Object
13 14 15 |
# File 'lib/lion_attr/internal_redis.rb', line 13 def set(key, value) redis.with { |c| c.hset @hash_name, key, value } end |
#setnx(key, value) ⇒ Object
25 26 27 |
# File 'lib/lion_attr/internal_redis.rb', line 25 def setnx(key, value) redis.with { |c| c.hsetnx @hash_name, key, value } end |