Class: LionAttr::InternalRedis

Inherits:
Object
  • Object
show all
Defined in:
lib/lion_attr/internal_redis.rb

Overview

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(hash_name) ⇒ InternalRedis

Returns a new instance of InternalRedis.

Since:

  • 0.1.0



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

Since:

  • 0.1.0



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

Since:

  • 0.1.0



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

Since:

  • 0.1.0



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

Since:

  • 0.1.0



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

Since:

  • 0.1.0



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

Since:

  • 0.1.0



38
39
40
# File 'lib/lion_attr/internal_redis.rb', line 38

def mget(keys)
  redis.with { |c| c.hmget @hash_name, keys }
end

#redisObject

Since:

  • 0.1.0



42
43
44
# File 'lib/lion_attr/internal_redis.rb', line 42

def redis
  RedisPool.instance
end

#set(key, value) ⇒ Object

Since:

  • 0.1.0



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

Since:

  • 0.1.0



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