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

Instance Method Details

#delete!Boolean Also known as: clear

Deletes the entire Redis key

Returns:

  • (Boolean)

    true if the key was deleted, false otherwise



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

Returns:

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

#persistObject



50
51
52
# File 'lib/familia/redistype/commands.rb', line 50

def persist
  redis.persist rediskey
end

#realttlObject



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

#typeObject



21
22
23
# File 'lib/familia/redistype/commands.rb', line 21

def type
  redis.type rediskey
end