Module: Oxblood::Commands::Keys
- Included in:
- Oxblood::Commands
- Defined in:
- lib/oxblood/commands/keys.rb
Instance Method Summary collapse
-
#del(*keys) ⇒ Integer
Delete a key.
-
#dump(key) ⇒ String
Return a serialized version of the value stored at specified key.
-
#exists(*keys) ⇒ Integer
Determine if a key exists.
-
#expire(key, seconds) ⇒ Integer
Set a key’s time to live in seconds.
-
#expireat(key, timestamp) ⇒ Integer
Set the expiration for a key as a UNIX timestamp.
-
#keys(pattern) ⇒ Object
Find all keys matching the given pattern.
-
#move(key, db) ⇒ Integer
Move a key to another database.
-
#object(subcommand, key) ⇒ Integer, ...
Inspect the internals of Redis objects.
-
#persist(key) ⇒ Integer
Remove expiration from a key.
-
#pexpire(key, milliseconds) ⇒ Integer
Set a key’s time to live in milliseconds.
-
#pexpireat(key, timestamp) ⇒ Integer
Set the expiration for a key as a UNIX timestamp specified in milliseconds.
-
#pttl(key) ⇒ Integer
Get the time to live for a key in milliseconds.
-
#randomkey ⇒ String?
Return a random key from the keyspace.
-
#rename(key, newkey) ⇒ String, RError
Rename a key.
-
#renamenx(key, newkey) ⇒ Integer, RError
Rename a key, only if the new key does not exist.
-
#restore(key, ttl, serialized_value, opts = {}) ⇒ String, RError
Create a key using the provided serialized value, previously obtained using DUMP.
-
#scan(cursor, opts = {}) ⇒ Array
Incrementally iterate the keys space.
-
#ttl(key) ⇒ Integer
Get the time to live for a key.
-
#type(key) ⇒ String
Determine the type stored at key.
Instance Method Details
#del(*keys) ⇒ Integer
Delete a key
12 13 14 |
# File 'lib/oxblood/commands/keys.rb', line 12 def del(*keys) run(*keys.unshift(:DEL)) end |
#dump(key) ⇒ String
Return a serialized version of the value stored at specified key.
22 23 24 |
# File 'lib/oxblood/commands/keys.rb', line 22 def dump(key) run(:DUMP, key) end |
#exists(*keys) ⇒ Integer
Determine if a key exists
34 35 36 |
# File 'lib/oxblood/commands/keys.rb', line 34 def exists(*keys) run(*keys.unshift(:EXISTS)) end |
#expire(key, seconds) ⇒ Integer
Set a key’s time to live in seconds
46 47 48 |
# File 'lib/oxblood/commands/keys.rb', line 46 def expire(key, seconds) run(:EXPIRE, key, seconds) end |
#expireat(key, timestamp) ⇒ Integer
Set the expiration for a key as a UNIX timestamp
58 59 60 |
# File 'lib/oxblood/commands/keys.rb', line 58 def expireat(key, ) run(:EXPIREAT, key, ) end |
#keys(pattern) ⇒ Object
Find all keys matching the given pattern
66 67 68 |
# File 'lib/oxblood/commands/keys.rb', line 66 def keys(pattern) run(:KEYS, pattern) end |
#move(key, db) ⇒ Integer
Move a key to another database
77 78 79 |
# File 'lib/oxblood/commands/keys.rb', line 77 def move(key, db) run(:MOVE, key, db) end |
#object(subcommand, key) ⇒ Integer, ...
Inspect the internals of Redis objects
90 91 92 |
# File 'lib/oxblood/commands/keys.rb', line 90 def object(subcommand, key) run(:OBJECT, subcommand, key) end |
#persist(key) ⇒ Integer
Remove expiration from a key
99 100 101 |
# File 'lib/oxblood/commands/keys.rb', line 99 def persist(key) run(:PERSIST, key) end |
#pexpire(key, milliseconds) ⇒ Integer
Set a key’s time to live in milliseconds
110 111 112 |
# File 'lib/oxblood/commands/keys.rb', line 110 def pexpire(key, milliseconds) run(:PEXPIRE, key, milliseconds) end |
#pexpireat(key, timestamp) ⇒ Integer
Set the expiration for a key as a UNIX timestamp specified in milliseconds
121 122 123 |
# File 'lib/oxblood/commands/keys.rb', line 121 def pexpireat(key, ) run(:PEXPIREAT, key, ) end |
#pttl(key) ⇒ Integer
Get the time to live for a key in milliseconds
132 133 134 |
# File 'lib/oxblood/commands/keys.rb', line 132 def pttl(key) run(:PTTL, key) end |
#randomkey ⇒ String?
Return a random key from the keyspace
141 142 143 |
# File 'lib/oxblood/commands/keys.rb', line 141 def randomkey run(:RANDOMKEY) end |
#rename(key, newkey) ⇒ String, RError
Rename a key
154 155 156 |
# File 'lib/oxblood/commands/keys.rb', line 154 def rename(key, newkey) run(:RENAME, key, newkey) end |
#renamenx(key, newkey) ⇒ Integer, RError
Rename a key, only if the new key does not exist
168 169 170 |
# File 'lib/oxblood/commands/keys.rb', line 168 def renamenx(key, newkey) run(:RENAMENX, key, newkey) end |
#restore(key, ttl, serialized_value, opts = {}) ⇒ String, RError
Create a key using the provided serialized value, previously obtained using DUMP
186 187 188 189 190 191 |
# File 'lib/oxblood/commands/keys.rb', line 186 def restore(key, ttl, serialized_value, opts = {}) args = [:RESTORE, key, ttl, serialized_value] args << :REPLACE if opts[:replace] run(*args) end |
#scan(cursor, opts = {}) ⇒ Array
Incrementally iterate the keys space
227 228 229 230 231 |
# File 'lib/oxblood/commands/keys.rb', line 227 def scan(cursor, opts = {}) args = [:SCAN, cursor] Scan.merge_opts!(args, opts) run(*args) end |
#ttl(key) ⇒ Integer
Get the time to live for a key
200 201 202 |
# File 'lib/oxblood/commands/keys.rb', line 200 def ttl(key) run(:TTL, key) end |
#type(key) ⇒ String
Determine the type stored at key
210 211 212 |
# File 'lib/oxblood/commands/keys.rb', line 210 def type(key) run(:TYPE, key) end |