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

Instance Method Details

#exists?Boolean

Returns:

  • (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

#hmset(suffix = nil) ⇒ Object



43
44
45
46
# File 'lib/familia/horreum/commands.rb', line 43

def hmset(suffix = nil)
  suffix ||= self.class.suffix
  redis.hmset rediskey(suffix), to_h
end

#realttlObject



31
32
33
# File 'lib/familia/horreum/commands.rb', line 31

def realttl
  redis.ttl rediskey
end

#redistype(suffix = nil) ⇒ Object



39
40
41
# File 'lib/familia/horreum/commands.rb', line 39

def redistype(suffix = nil)
  redis.type rediskey(suffix)
end