Module: Lite::Redis::KeyHelper

Included in:
Key, Key
Defined in:
lib/lite/redis/helpers/key_helper.rb

Instance Method Summary collapse

Instance Method Details

#destroy(key) ⇒ Object



39
40
41
# File 'lib/lite/redis/helpers/key_helper.rb', line 39

def destroy(key)
  client.del(key.to_s)
end

#dump(key) ⇒ Object



65
66
67
# File 'lib/lite/redis/helpers/key_helper.rb', line 65

def dump(key)
  client.dump(key.to_s)
end

#exists?(key) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/lite/redis/helpers/key_helper.rb', line 7

def exists?(key)
  client.exists(key.to_s)
end

#expire(key, seconds, format = :seconds) ⇒ Object Also known as: expire_in



47
48
49
50
51
52
53
# File 'lib/lite/redis/helpers/key_helper.rb', line 47

def expire(key, seconds, format = :seconds)
  if seconds?(format)
    client.expire(key.to_s, seconds)
  else
    client.pexpire(key.to_s, seconds)
  end
end

#expire_at(key, seconds, format = :seconds) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/lite/redis/helpers/key_helper.rb', line 57

def expire_at(key, seconds, format = :seconds)
  if seconds?(format)
    client.expireat(key.to_s, seconds)
  else
    client.pexpireat(key.to_s, seconds)
  end
end

#match(pattern = '*') ⇒ Object



69
70
71
# File 'lib/lite/redis/helpers/key_helper.rb', line 69

def match(pattern = '*')
  client.keys(pattern.to_s)
end

#migrate(key, options) ⇒ Object



73
74
75
# File 'lib/lite/redis/helpers/key_helper.rb', line 73

def migrate(key, options)
  client.migrate(key.to_s, options)
end

#move(key, destination) ⇒ Object



77
78
79
# File 'lib/lite/redis/helpers/key_helper.rb', line 77

def move(key, destination)
  client.move(key.to_s, destination)
end

#object(*args) ⇒ Object



81
82
83
# File 'lib/lite/redis/helpers/key_helper.rb', line 81

def object(*args)
  client.object(*args)
end

#persist(key) ⇒ Object



43
44
45
# File 'lib/lite/redis/helpers/key_helper.rb', line 43

def persist(key)
  client.persist(key.to_s)
end

#rename(key, value) ⇒ Object



31
32
33
# File 'lib/lite/redis/helpers/key_helper.rb', line 31

def rename(key, value)
  client.rename(key.to_s, value.to_s)
end

#rename!(key, value) ⇒ Object



35
36
37
# File 'lib/lite/redis/helpers/key_helper.rb', line 35

def rename!(key, value)
  client.renamenx(key.to_s, value.to_s)
end

#restore(key, milliseconds, value) ⇒ Object



85
86
87
# File 'lib/lite/redis/helpers/key_helper.rb', line 85

def restore(key, milliseconds, value)
  client.restore(key.to_s, milliseconds, value)
end

#sampleObject



27
28
29
# File 'lib/lite/redis/helpers/key_helper.rb', line 27

def sample
  client.randomkey
end

#scan(cursor, opts = {}) ⇒ Object



89
90
91
# File 'lib/lite/redis/helpers/key_helper.rb', line 89

def scan(cursor, opts = {})
  client.scan(cursor, **opts)
end

#sort(key, opts = {}) ⇒ Object



23
24
25
# File 'lib/lite/redis/helpers/key_helper.rb', line 23

def sort(key, opts = {})
  client.sort(key.to_s, **opts)
end

#ttl?(key, format = :seconds) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/lite/redis/helpers/key_helper.rb', line 15

def ttl?(key, format = :seconds)
  if seconds?(format)
    client.ttl(key.to_s)
  else
    client.pttl(key.to_s)
  end
end

#type?(key) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/lite/redis/helpers/key_helper.rb', line 11

def type?(key)
  client.type(key.to_s)
end