Class: ActiveOrm::Redis::Key
Class Method Summary collapse
- .destroy(key) ⇒ Object
- .dump(key) ⇒ Object
- .exists?(key) ⇒ Boolean
- .expire(key, seconds, format = :seconds) ⇒ Object
- .expire_at(key, seconds, format = :seconds) ⇒ Object
- .match(pattern = '*') ⇒ Object
- .migrate(key, options) ⇒ Object
- .move(key, destination) ⇒ Object
- .object(*args) ⇒ Object
- .persist(key) ⇒ Object
- .rename(key, value) ⇒ Object
- .rename!(key, value) ⇒ Object
- .restore(key, milliseconds, value) ⇒ Object
- .sample ⇒ Object
- .scan(cursor, opts = {}) ⇒ Object
- .sort(key, opts = {}) ⇒ Object
- .ttl?(key, format = :seconds) ⇒ Boolean
- .type?(key) ⇒ Boolean
Methods inherited from Base
Class Method Details
.destroy(key) ⇒ Object
36 37 38 |
# File 'lib/active_orm/redis/key.rb', line 36 def destroy(key) client.del(normalize_key(key)) end |
.dump(key) ⇒ Object
64 65 66 |
# File 'lib/active_orm/redis/key.rb', line 64 def dump(key) client.dump(normalize_key(key)) end |
.exists?(key) ⇒ Boolean
6 7 8 |
# File 'lib/active_orm/redis/key.rb', line 6 def exists?(key) client.exists(normalize_key(key)) end |
.expire(key, seconds, format = :seconds) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/active_orm/redis/key.rb', line 44 def expire(key, seconds, format = :seconds) normalized_key = normalize_key(key) if seconds?(format) client.expire(normalized_key, seconds) else client.pexpire(normalized_key, seconds) end end |
.expire_at(key, seconds, format = :seconds) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/active_orm/redis/key.rb', line 54 def expire_at(key, seconds, format = :seconds) normalized_key = normalize_key(key) if seconds?(format) client.expireat(normalized_key, seconds) else client.pexpireat(normalized_key, seconds) end end |
.match(pattern = '*') ⇒ Object
68 69 70 71 72 |
# File 'lib/active_orm/redis/key.rb', line 68 def match(pattern = '*') value = client.keys(normalize_key(pattern)) value = nil if value.empty? value end |
.migrate(key, options) ⇒ Object
74 75 76 |
# File 'lib/active_orm/redis/key.rb', line 74 def migrate(key, ) client.migrate(normalize_key(key), ) end |
.move(key, destination) ⇒ Object
78 79 80 |
# File 'lib/active_orm/redis/key.rb', line 78 def move(key, destination) client.move(normalize_key(key), destination) end |
.object(*args) ⇒ Object
82 83 84 |
# File 'lib/active_orm/redis/key.rb', line 82 def object(*args) client.object(args) end |
.persist(key) ⇒ Object
40 41 42 |
# File 'lib/active_orm/redis/key.rb', line 40 def persist(key) client.persist(normalize_key(key)) end |
.rename(key, value) ⇒ Object
28 29 30 |
# File 'lib/active_orm/redis/key.rb', line 28 def rename(key, value) client.rename(normalize_key(key), value.to_s) end |
.rename!(key, value) ⇒ Object
32 33 34 |
# File 'lib/active_orm/redis/key.rb', line 32 def rename!(key, value) client.renamenx(normalize_key(key), value.to_s) end |
.restore(key, milliseconds, value) ⇒ Object
86 87 88 |
# File 'lib/active_orm/redis/key.rb', line 86 def restore(key, milliseconds, value) client.restore(normalize_key(key), milliseconds, value) end |
.sample ⇒ Object
24 25 26 |
# File 'lib/active_orm/redis/key.rb', line 24 def sample client.randomkey end |
.scan(cursor, opts = {}) ⇒ Object
90 91 92 |
# File 'lib/active_orm/redis/key.rb', line 90 def scan(cursor, opts = {}) client.scan(cursor, opts) end |
.sort(key, opts = {}) ⇒ Object
20 21 22 |
# File 'lib/active_orm/redis/key.rb', line 20 def sort(key, opts = {}) client.sort(normalize_key(key), opts) end |
.ttl?(key, format = :seconds) ⇒ Boolean
14 15 16 17 18 |
# File 'lib/active_orm/redis/key.rb', line 14 def ttl?(key, format = :seconds) normalized_key = normalize_key(key) seconds?(format) ? client.ttl(normalized_key) : client.pttl(normalized_key) end |
.type?(key) ⇒ Boolean
10 11 12 |
# File 'lib/active_orm/redis/key.rb', line 10 def type?(key) client.type(normalize_key(key)) end |