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

Instance Method Details

#current_expirationObject



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

Returns:

  • (Boolean)

    true if the key was deleted, false otherwise



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

Returns:

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

#persistObject



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

#typeObject



19
20
21
# File 'lib/familia/data_type/commands.rb', line 19

def type
  dbclient.type dbkey
end