Class: ActiveOrm::Redis::Key

Inherits:
ActiveOrm::Redis show all
Defined in:
lib/active_orm/redis/key.rb

Instance Attribute Summary

Attributes inherited from ActiveOrm::Redis

#client

Attributes inherited from Base

#configuration

Class Method Summary collapse

Methods inherited from ActiveOrm::Redis

client, #initialize

Methods included from Base

#evaluate, #evaluate?

Methods inherited from Base

configuration, configuration=, configure

Constructor Details

This class inherits a constructor from ActiveOrm::Redis

Class Method Details

.destroy(key) ⇒ Object



31
32
33
# File 'lib/active_orm/redis/key.rb', line 31

def self.destroy(key)
  client.del(normalize_key(key))
end

.dump(key) ⇒ Object



47
48
49
# File 'lib/active_orm/redis/key.rb', line 47

def self.dump(key)
  client.dump(normalize_key(key))
end

.exists?(key) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/active_orm/redis/key.rb', line 3

def self.exists?(key)
  client.exists(normalize_key(key))
end

.expire(key, seconds, format = :seconds) ⇒ Object



39
40
41
# File 'lib/active_orm/redis/key.rb', line 39

def self.expire(key, seconds, format=:seconds)
  seconds?(format) ? client.expire(normalize_key(key), seconds) : client.pexpire(normalize_key(key), seconds)
end

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



43
44
45
# File 'lib/active_orm/redis/key.rb', line 43

def self.expire_at(key, seconds, format=:seconds)
  seconds?(format) ? client.expireat(normalize_key(key), seconds) : client.pexpireat(normalize_key(key), seconds)
end

.match(pattern = '*'.freeze) ⇒ Object



51
52
53
54
55
# File 'lib/active_orm/redis/key.rb', line 51

def self.match(pattern='*'.freeze)
  value = client.keys(normalize_key(pattern))
  value = nil if value.empty?
  return(value)
end

.migrate(key, options) ⇒ Object



57
58
59
# File 'lib/active_orm/redis/key.rb', line 57

def self.migrate(key, options)
  client.migrate(normalize_key(key), options)
end

.move(key, destination) ⇒ Object



61
62
63
# File 'lib/active_orm/redis/key.rb', line 61

def self.move(key, destination)
  client.move(normalize_key(key), destination)
end

.object(*args) ⇒ Object



65
66
67
# File 'lib/active_orm/redis/key.rb', line 65

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

.persist(key) ⇒ Object



35
36
37
# File 'lib/active_orm/redis/key.rb', line 35

def self.persist(key)
  client.persist(normalize_key(key))
end

.rename(key, value) ⇒ Object



23
24
25
# File 'lib/active_orm/redis/key.rb', line 23

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

.rename!(key, value) ⇒ Object



27
28
29
# File 'lib/active_orm/redis/key.rb', line 27

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

.restore(key, milliseconds, value) ⇒ Object



69
70
71
# File 'lib/active_orm/redis/key.rb', line 69

def self.restore(key, milliseconds, value)
  client.restore(normalize_key(key), milliseconds, value)
end

.sampleObject



19
20
21
# File 'lib/active_orm/redis/key.rb', line 19

def self.sample
  client.randomkey
end

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



77
78
79
# File 'lib/active_orm/redis/key.rb', line 77

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

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



15
16
17
# File 'lib/active_orm/redis/key.rb', line 15

def self.sort(key, opts={})
  client.sort(normalize_key(key), opts)
end

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

Returns:

  • (Boolean)


11
12
13
# File 'lib/active_orm/redis/key.rb', line 11

def self.ttl?(key, format=:seconds)
  seconds?(format) ? client.ttl(normalize_key(key)) : client.pttl(normalize_key(key))
end

.type?(key) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/active_orm/redis/key.rb', line 7

def self.type?(key)
  client.type(normalize_key(key))
end