Module: Familia::RedisType::Commands
- Included in:
- Familia::RedisType
- Defined in:
- lib/familia/redistype/commands.rb
Overview
Must be included in all RedisType classes to provide Redis commands. The class must have a rediskey method.
Instance Method Summary collapse
-
#delete! ⇒ Boolean
(also: #clear)
Deletes the entire Redis key.
- #echo(meth, trace) ⇒ Object
- #exists? ⇒ Boolean
- #expire(sec) ⇒ Object
- #expireat(unixtime) ⇒ Object
- #move(db) ⇒ Object
- #persist ⇒ Object
- #realttl ⇒ Object
- #rename(newkey) ⇒ Object
- #renamenx(newkey) ⇒ Object
- #type ⇒ Object
Instance Method Details
#delete! ⇒ Boolean Also known as: clear
Deletes the entire Redis key
27 28 29 30 31 |
# File 'lib/familia/redistype/commands.rb', line 27 def delete! Familia.trace :DELETE!, redis, redisuri, caller(1..1) if Familia.debug? ret = redis.del rediskey ret.positive? end |
#echo(meth, trace) ⇒ Object
54 55 56 |
# File 'lib/familia/redistype/commands.rb', line 54 def echo(meth, trace) redis.echo "[#{self.class}\##{meth}] #{trace} (#{@opts[:class]}\#)" end |
#exists? ⇒ Boolean
34 35 36 |
# File 'lib/familia/redistype/commands.rb', line 34 def exists? redis.exists(rediskey) && !size.zero? end |
#expire(sec) ⇒ Object
42 43 44 |
# File 'lib/familia/redistype/commands.rb', line 42 def expire(sec) redis.expire rediskey, sec.to_i end |
#expireat(unixtime) ⇒ Object
46 47 48 |
# File 'lib/familia/redistype/commands.rb', line 46 def expireat(unixtime) redis.expireat rediskey, unixtime end |
#move(db) ⇒ Object
9 10 11 |
# File 'lib/familia/redistype/commands.rb', line 9 def move(db) redis.move rediskey, db end |
#persist ⇒ Object
50 51 52 |
# File 'lib/familia/redistype/commands.rb', line 50 def persist redis.persist rediskey end |
#realttl ⇒ Object
38 39 40 |
# File 'lib/familia/redistype/commands.rb', line 38 def realttl redis.ttl rediskey end |
#rename(newkey) ⇒ Object
13 14 15 |
# File 'lib/familia/redistype/commands.rb', line 13 def rename(newkey) redis.rename rediskey, newkey end |
#renamenx(newkey) ⇒ Object
17 18 19 |
# File 'lib/familia/redistype/commands.rb', line 17 def renamenx(newkey) redis.renamenx rediskey, newkey end |
#type ⇒ Object
21 22 23 |
# File 'lib/familia/redistype/commands.rb', line 21 def type redis.type rediskey end |