Module: Familia::DataType::Commands
- Included in:
- Familia::DataType
- Defined in:
- lib/familia/data_type/commands.rb
Overview
Must be included in all DataType classes to provide Redis commands. The class must have a dbkey method.
Instance Method Summary collapse
-
#current_expiration ⇒ Object
-
#delete! ⇒ Boolean
(also: #clear)
Deletes the entire dbkey.
-
#echo(meth, trace) ⇒ Object
-
#exists? ⇒ Boolean
-
#expire(sec) ⇒ Object
-
#expireat(unixtime) ⇒ Object
-
#move(logical_database) ⇒ Object
-
#persist ⇒ Object
-
#rename(newkey) ⇒ Object
-
#renamenx(newkey) ⇒ Object
-
#type ⇒ Object
Instance Method Details
#current_expiration ⇒ Object
36 37 38 |
# File 'lib/familia/data_type/commands.rb', line 36 def current_expiration dbclient.ttl dbkey end |
#delete! ⇒ Boolean Also known as: clear
Deletes the entire dbkey
25 26 27 28 29 |
# File 'lib/familia/data_type/commands.rb', line 25 def delete! Familia.trace :DELETE!, dbclient, uri, caller(1..1) if Familia.debug? ret = dbclient.del dbkey ret.positive? end |
#echo(meth, trace) ⇒ Object
52 53 54 |
# File 'lib/familia/data_type/commands.rb', line 52 def echo(meth, trace) dbclient.echo "[#{self.class}##{meth}] #{trace} (#{@opts[:class]}#)" end |
#exists? ⇒ Boolean
32 33 34 |
# File 'lib/familia/data_type/commands.rb', line 32 def exists? dbclient.exists(dbkey) && !size.zero? end |
#expire(sec) ⇒ Object
40 41 42 |
# File 'lib/familia/data_type/commands.rb', line 40 def expire(sec) dbclient.expire dbkey, sec.to_i end |
#expireat(unixtime) ⇒ Object
44 45 46 |
# File 'lib/familia/data_type/commands.rb', line 44 def expireat(unixtime) dbclient.expireat dbkey, unixtime end |
#move(logical_database) ⇒ Object
7 8 9 |
# File 'lib/familia/data_type/commands.rb', line 7 def move(logical_database) dbclient.move dbkey, logical_database end |
#persist ⇒ Object
48 49 50 |
# File 'lib/familia/data_type/commands.rb', line 48 def persist dbclient.persist dbkey end |
#rename(newkey) ⇒ Object
11 12 13 |
# File 'lib/familia/data_type/commands.rb', line 11 def rename(newkey) dbclient.rename dbkey, newkey end |
#renamenx(newkey) ⇒ Object
15 16 17 |
# File 'lib/familia/data_type/commands.rb', line 15 def renamenx(newkey) dbclient.renamenx dbkey, newkey end |
#type ⇒ Object
19 20 21 |
# File 'lib/familia/data_type/commands.rb', line 19 def type dbclient.type dbkey end |