Class: RedisRds::Hash
- Inherits:
-
Object
show all
- Includes:
- Enumerable
- Defined in:
- lib/redis_rds/hash.rb
Instance Attribute Summary
Attributes inherited from Object
#redis_key
Instance Method Summary
collapse
Methods inherited from Object
configure, #connection, connection, #delete, #dump, #exists?, #expire, #expireat, flushdb, #initialize, #namespace, #persist, #pttl, #ttl, #type
Instance Method Details
51
52
53
|
# File 'lib/redis_rds/hash.rb', line 51
def all
return (getall || {}).with_indifferent_access
end
|
#decr(key) ⇒ Object
43
44
45
|
# File 'lib/redis_rds/hash.rb', line 43
def decr(key)
return incrby(key, -1)
end
|
#decrby(key, decrement) ⇒ Object
47
48
49
|
# File 'lib/redis_rds/hash.rb', line 47
def decrby(key, decrement)
return incrby(key, -decrement)
end
|
#each(&block) ⇒ Object
TODO: Implement lazy enumerator
72
73
74
|
# File 'lib/redis_rds/hash.rb', line 72
def each(&block)
return all.each(&block)
end
|
#get(key) ⇒ Object
Also known as:
[]
5
6
7
|
# File 'lib/redis_rds/hash.rb', line 5
def get(key)
return connection.hget(@redis_key, key)
end
|
55
56
57
|
# File 'lib/redis_rds/hash.rb', line 55
def getall
return connection.hgetall(@redis_key)
end
|
#incr(key) ⇒ Object
39
40
41
|
# File 'lib/redis_rds/hash.rb', line 39
def incr(key)
return incrby(key, 1)
end
|
#incrby(key, increment) ⇒ Object
31
32
33
|
# File 'lib/redis_rds/hash.rb', line 31
def incrby(key, increment)
return connection.hincrby(@redis_key, key, increment)
end
|
#key?(key) ⇒ Boolean
35
36
37
|
# File 'lib/redis_rds/hash.rb', line 35
def key?(key)
return connection.hexists(@redis_key, key)
end
|
63
64
65
|
# File 'lib/redis_rds/hash.rb', line 63
def keys
return all.keys
end
|
#mget(*_args) ⇒ Object
19
20
21
|
# File 'lib/redis_rds/hash.rb', line 19
def mget(*_args)
return connection.hmget(@redis_key, *arg)
end
|
#mset(*args) ⇒ Object
15
16
17
|
# File 'lib/redis_rds/hash.rb', line 15
def mset(*args)
return connection.hmset(@redis_key, *args)
end
|
#remove(key) ⇒ Object
27
28
29
|
# File 'lib/redis_rds/hash.rb', line 27
def remove(key)
return connection.hdel(@redis_key, key)
end
|
#set(key, value) ⇒ Object
Also known as:
[]=
10
11
12
|
# File 'lib/redis_rds/hash.rb', line 10
def set(key, value)
return connection.hset(@redis_key, key, value)
end
|
#setnx(key, value) ⇒ Object
23
24
25
|
# File 'lib/redis_rds/hash.rb', line 23
def setnx(key, value)
return connection.hsetnx(@redis_key, key, value)
end
|
67
68
69
|
# File 'lib/redis_rds/hash.rb', line 67
def to_json
return all.to_json
end
|
59
60
61
|
# File 'lib/redis_rds/hash.rb', line 59
def values
return all.values
end
|