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.
-
#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
10 11 12 |
# File 'lib/oxblood/commands/keys.rb', line 10 def del(*keys) run(*keys.unshift(:DEL)) end |
#dump(key) ⇒ String
Return a serialized version of the value stored at specified key.
20 21 22 |
# File 'lib/oxblood/commands/keys.rb', line 20 def dump(key) run(:DUMP, key) end |
#exists(*keys) ⇒ Integer
Determine if a key exists
32 33 34 |
# File 'lib/oxblood/commands/keys.rb', line 32 def exists(*keys) run(*keys.unshift(:EXISTS)) end |
#expire(key, seconds) ⇒ Integer
Set a key’s time to live in seconds
44 45 46 |
# File 'lib/oxblood/commands/keys.rb', line 44 def expire(key, seconds) run(:EXPIRE, key, seconds) end |
#expireat(key, timestamp) ⇒ Integer
Set the expiration for a key as a UNIX timestamp
56 57 58 |
# File 'lib/oxblood/commands/keys.rb', line 56 def expireat(key, ) run(:EXPIREAT, key, ) end |
#keys(pattern) ⇒ Object
Find all keys matching the given pattern
64 65 66 |
# File 'lib/oxblood/commands/keys.rb', line 64 def keys(pattern) run(:KEYS, pattern) end |
#move(key, db) ⇒ Integer
Move a key to another database
75 76 77 |
# File 'lib/oxblood/commands/keys.rb', line 75 def move(key, db) run(:MOVE, key, db) end |
#object(subcommand, key) ⇒ Integer, ...
Inspect the internals of Redis objects
88 89 90 |
# File 'lib/oxblood/commands/keys.rb', line 88 def object(subcommand, key) run(:OBJECT, subcommand, key) end |
#persist(key) ⇒ Integer
Remove expiration from a key
97 98 99 |
# File 'lib/oxblood/commands/keys.rb', line 97 def persist(key) run(:PERSIST, key) end |
#pexpire(key, milliseconds) ⇒ Integer
Set a key’s time to live in milliseconds
108 109 110 |
# File 'lib/oxblood/commands/keys.rb', line 108 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
119 120 121 |
# File 'lib/oxblood/commands/keys.rb', line 119 def pexpireat(key, ) run(:PEXPIREAT, key, ) end |
#pttl(key) ⇒ Integer
Get the time to live for a key in milliseconds
130 131 132 |
# File 'lib/oxblood/commands/keys.rb', line 130 def pttl(key) run(:PTTL, key) end |
#randomkey ⇒ String?
Return a random key from the keyspace
139 140 141 |
# File 'lib/oxblood/commands/keys.rb', line 139 def randomkey run(:RANDOMKEY) end |
#rename(key, newkey) ⇒ String, RError
Rename a key
152 153 154 |
# File 'lib/oxblood/commands/keys.rb', line 152 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
166 167 168 |
# File 'lib/oxblood/commands/keys.rb', line 166 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
184 185 186 187 188 189 |
# File 'lib/oxblood/commands/keys.rb', line 184 def restore(key, ttl, serialized_value, opts = {}) args = [:RESTORE, key, ttl, serialized_value] args << :REPLACE if opts[:replace] run(*args) end |
#ttl(key) ⇒ Integer
Get the time to live for a key
198 199 200 |
# File 'lib/oxblood/commands/keys.rb', line 198 def ttl(key) run(:TTL, key) end |
#type(key) ⇒ String
Determine the type stored at key
208 209 210 |
# File 'lib/oxblood/commands/keys.rb', line 208 def type(key) run(:TYPE, key) end |