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 Valkey/Redis commands. The class must have a dbkey method.

Instance Method Summary collapse

Instance Method Details

#current_expirationObject



37
38
39
# File 'lib/familia/data_type/commands.rb', line 37

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



26
27
28
29
30
# File 'lib/familia/data_type/commands.rb', line 26

def delete!
  Familia.trace :DELETE!, nil, uri if Familia.debug?
  ret = dbclient.del dbkey
  ret.positive?
end

#echo(*args) ⇒ Object



53
54
55
# File 'lib/familia/data_type/commands.rb', line 53

def echo(*args)
  dbclient.echo "[#{self.class}] #{args.join(' ')} (#{opts&.fetch(:class, '<no opts>')})"
end

#exists?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/familia/data_type/commands.rb', line 33

def exists?
  dbclient.exists(dbkey) && !size.zero?
end

#expire(sec) ⇒ Object



41
42
43
# File 'lib/familia/data_type/commands.rb', line 41

def expire(sec)
  dbclient.expire dbkey, sec.to_i
end

#expireat(unixtime) ⇒ Object



45
46
47
# File 'lib/familia/data_type/commands.rb', line 45

def expireat(unixtime)
  dbclient.expireat dbkey, unixtime
end

#move(logical_database) ⇒ Object



8
9
10
# File 'lib/familia/data_type/commands.rb', line 8

def move(logical_database)
  dbclient.move dbkey, logical_database
end

#persistObject



49
50
51
# File 'lib/familia/data_type/commands.rb', line 49

def persist
  dbclient.persist dbkey
end

#rename(newkey) ⇒ Object



12
13
14
# File 'lib/familia/data_type/commands.rb', line 12

def rename(newkey)
  dbclient.rename dbkey, newkey
end

#renamenx(newkey) ⇒ Object



16
17
18
# File 'lib/familia/data_type/commands.rb', line 16

def renamenx(newkey)
  dbclient.renamenx dbkey, newkey
end

#typeObject



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

def type
  dbclient.type dbkey
end