Module: Familia::Horreum::Commands
- Included in:
- Familia::Horreum
- Defined in:
- lib/familia/horreum/commands.rb
Overview
Methods that call Redis commands (InstanceMethods)
NOTE: There is no hgetall for Horreum. This is because Horreum is a single hash in Redis that we aren’t meant to have be working on in memory for more than, making changes -> committing. To emphasize this, instead of “refreshing” the object with hgetall, just load the object again.
Instance Method Summary collapse
- #exists? ⇒ Boolean
- #expire(ttl = nil) ⇒ Object
- #hdel!(field) ⇒ Object
- #hget(field) ⇒ Object
-
#hgetall ⇒ Object
(also: #all)
For parity with RedisType#hgetall.
- #hincrby(field, increment) ⇒ Object
- #hincrbyfloat(field, increment) ⇒ Object
- #hkeys ⇒ Object
- #hlen ⇒ Object
- #hmset ⇒ Object
-
#hset(field, value) ⇒ Object
The number of fields that were added to the hash.
- #hstrlen(field) ⇒ Object
- #hvals ⇒ Object
- #realttl ⇒ Object
- #redistype ⇒ Object
-
#rename(newkey) ⇒ Object
Parity with RedisType#rename.
Instance Method Details
#exists? ⇒ Boolean
21 22 23 24 |
# File 'lib/familia/horreum/commands.rb', line 21 def exists? ret = redis.exists rediskey ret.positive? end |
#expire(ttl = nil) ⇒ Object
26 27 28 29 |
# File 'lib/familia/horreum/commands.rb', line 26 def expire(ttl = nil) ttl ||= self.class.ttl redis.expire rediskey, ttl.to_i end |
#hdel!(field) ⇒ Object
35 36 37 |
# File 'lib/familia/horreum/commands.rb', line 35 def hdel!(field) redis.hdel rediskey, field end |
#hget(field) ⇒ Object
55 56 57 |
# File 'lib/familia/horreum/commands.rb', line 55 def hget(field) redis.hget rediskey(suffix), field end |
#hgetall ⇒ Object Also known as: all
For parity with RedisType#hgetall
49 50 51 52 |
# File 'lib/familia/horreum/commands.rb', line 49 def hgetall Familia.trace :HGETALL, redis, redisuri, caller(1..1) if Familia.debug? redis.hgetall rediskey(suffix) end |
#hincrby(field, increment) ⇒ Object
79 80 81 |
# File 'lib/familia/horreum/commands.rb', line 79 def hincrby(field, increment) redis.hincrby rediskey(suffix), field, increment end |
#hincrbyfloat(field, increment) ⇒ Object
83 84 85 |
# File 'lib/familia/horreum/commands.rb', line 83 def hincrbyfloat(field, increment) redis.hincrbyfloat rediskey(suffix), field, increment end |
#hkeys ⇒ Object
70 71 72 73 |
# File 'lib/familia/horreum/commands.rb', line 70 def hkeys Familia.trace :HKEYS, redis, 'redisuri', caller(1..1) if Familia.debug? redis.hkeys rediskey(suffix) end |
#hlen ⇒ Object
87 88 89 |
# File 'lib/familia/horreum/commands.rb', line 87 def hlen redis.hlen rediskey(suffix) end |
#hmset ⇒ Object
66 67 68 |
# File 'lib/familia/horreum/commands.rb', line 66 def hmset redis.hmset rediskey(suffix), self.to_h end |
#hset(field, value) ⇒ Object
Returns The number of fields that were added to the hash. If the field already exists, this will return 0.
61 62 63 64 |
# File 'lib/familia/horreum/commands.rb', line 61 def hset(field, value) Familia.trace :HSET, redis, redisuri, caller(1..1) if Familia.debug? redis.hset rediskey, field, value end |
#hstrlen(field) ⇒ Object
91 92 93 |
# File 'lib/familia/horreum/commands.rb', line 91 def hstrlen(field) redis.hstrlen rediskey(suffix), field end |
#hvals ⇒ Object
75 76 77 |
# File 'lib/familia/horreum/commands.rb', line 75 def hvals redis.hvals rediskey(suffix) end |
#realttl ⇒ Object
31 32 33 |
# File 'lib/familia/horreum/commands.rb', line 31 def realttl redis.ttl rediskey end |
#redistype ⇒ Object
39 40 41 |
# File 'lib/familia/horreum/commands.rb', line 39 def redistype redis.type rediskey(suffix) end |
#rename(newkey) ⇒ Object
Parity with RedisType#rename
44 45 46 |
# File 'lib/familia/horreum/commands.rb', line 44 def rename(newkey) redis.rename rediskey, newkey end |