Module: Familia::DataType::Commands
- Included in:
- Familia::DataType
- Defined in:
- lib/familia/datatype/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
38 39 40 |
# File 'lib/familia/datatype/commands.rb', line 38 def current_expiration dbclient.ttl dbkey end |
#delete! ⇒ Boolean Also known as: clear
Deletes the entire dbkey
27 28 29 30 31 |
# File 'lib/familia/datatype/commands.rb', line 27 def delete! Familia.trace :DELETE!, dbclient, uri, caller(1..1) if Familia.debug? ret = dbclient.del dbkey ret.positive? end |
#echo(meth, trace) ⇒ Object
54 55 56 |
# File 'lib/familia/datatype/commands.rb', line 54 def echo(meth, trace) dbclient.echo "[#{self.class}\##{meth}] #{trace} (#{@opts[:class]}\#)" end |
#exists? ⇒ Boolean
34 35 36 |
# File 'lib/familia/datatype/commands.rb', line 34 def exists? dbclient.exists(dbkey) && !size.zero? end |
#expire(sec) ⇒ Object
42 43 44 |
# File 'lib/familia/datatype/commands.rb', line 42 def expire(sec) dbclient.expire dbkey, sec.to_i end |
#expireat(unixtime) ⇒ Object
46 47 48 |
# File 'lib/familia/datatype/commands.rb', line 46 def expireat(unixtime) dbclient.expireat dbkey, unixtime end |
#move(logical_database) ⇒ Object
9 10 11 |
# File 'lib/familia/datatype/commands.rb', line 9 def move(logical_database) dbclient.move dbkey, logical_database end |
#persist ⇒ Object
50 51 52 |
# File 'lib/familia/datatype/commands.rb', line 50 def persist dbclient.persist dbkey end |
#rename(newkey) ⇒ Object
13 14 15 |
# File 'lib/familia/datatype/commands.rb', line 13 def rename(newkey) dbclient.rename dbkey, newkey end |
#renamenx(newkey) ⇒ Object
17 18 19 |
# File 'lib/familia/datatype/commands.rb', line 17 def renamenx(newkey) dbclient.renamenx dbkey, newkey end |
#type ⇒ Object
21 22 23 |
# File 'lib/familia/datatype/commands.rb', line 21 def type dbclient.type dbkey end |