Deletes one or multiple keys.
Deletes one or multiple keys.
key(s) to delete
the number of keys that were deleted
1.0.0
a key is ignored if it does not exist
Returns a serialized version of the value stored at the specified key.
Returns a serialized version of the value stored at the specified key.
key to dump
the serialized value or None
if the key does not exist
2.6.0
Determines if a key exists.
Determines if a key exists.
key to check for existence
true if the key exists, false otherwise
1.0.0
Sets a key's time to live in seconds.
Sets a key's time to live in seconds.
key to expire
time-to-live in seconds
true if the ttl was set, false if key does not exist or the timeout could not be set
1.0.0
Sets the expiration for a key as a UNIX timestamp.
Sets the expiration for a key as a UNIX timestamp.
key to expire
UNIX timestamp at which the key should expire
true if the ttl was set, false if key does not exist or the timeout could not be set
1.2.0
Finds all keys matching the given pattern.
Finds all keys matching the given pattern.
pattern to search for
the matched keys, or the empty set if no keys match the given pattern
1.0.0
Atomically transfers a key from a Redis instance to another one.
Atomically transfers a key from a Redis instance to another one.
key to transfer
destination host
destination port
destination database
timeout duration, up to milliseconds precision
if true, do not remove the key from the local instance
if true, replace existing key on the remote instance
2.6.0
[[scredis.exceptions.RedisErrorResponseException]]
if an error occurs
Moves a key to another database.
Moves a key to another database.
key to move
destination database
true if key was moved, false otherwise
1.0.0
Returns the kind of internal representation used in order to store the value associated with a key.
Returns the kind of internal representation used in order to store the value associated with a key.
the key
the object encoding or None
if the key does not exist
2.2.3
Objects can be encoded in different ways:
Strings can be encoded as raw
or int
Lists can be encoded as ziplist
or linkedlist
Sets can be encoded as intset
or hashtable
Hashes can be encoded as zipmap
or hashtable
SortedSets can be encoded as ziplist
or skiplist
Returns the number of seconds since the object stored at the specified key is idle (not requested by read or write operations).
Returns the number of seconds since the object stored at the specified key is idle (not requested by read or write operations).
the key
the number of seconds since the object is idle or None
if the key does not exist
2.2.3
While the value is returned in seconds the actual resolution of this timer is 10 seconds, but may vary in future implementations.
Returns the number of references of the value associated with the specified key.
Returns the number of references of the value associated with the specified key.
the key
the number of references or None
if the key does not exist
2.2.3
Sets a key's time to live in milliseconds.
Sets a key's time to live in milliseconds.
key to expire
time-to-live in milliseconds
true if the ttl was set, false if key does not exist or the timeout could not be set
2.6.0
Sets the expiration for a key as a UNIX timestamp specified in milliseconds.
Sets the expiration for a key as a UNIX timestamp specified in milliseconds.
key to expire
UNIX milliseconds-timestamp at which the key should expire
true if the ttl was set, false if key does not exist or the timeout could not be set
2.6.0
Gets the time to live for a key in milliseconds.
Gets the time to live for a key in milliseconds.
result match { case Left(false) => // key does not exist case Left(true) => // key exists but has no associated expire case Right(ttl) => }
the target key
Right(ttl)
where ttl is the time-to-live in milliseconds for specified key,
Left(false)
if key does not exist or Left(true)
if key exists but has no associated
expire
2.6.0
For Redis
version <= 2.8.x, Left(false)
will be returned when the key does not
exists and when it exists but has no associated expire (Redis
returns the same error code
for both cases). In other words, you can simply check the following
result match { case Left(_) => case Right(ttl) => }
Removes the expiration from a key.
Removes the expiration from a key.
key to persist
true if key was persisted, false if key does not exist or does not have an associated timeout
2.2.0
Returns a random key from the keyspace.
Returns a random key from the keyspace.
the random key or None
when the database is empty
associated timeout
1.0.0
Renames a key.
Renames a key.
source key
destination key
1.0.0
[[scredis.exceptions.RedisErrorResponseException]]
if the source and destination keys are the same, or when key
does not exist
if newKey already exists, it is overwritten
Renames a key, only if the new key does not exist.
Renames a key, only if the new key does not exist.
source key
destination key
true if key was renamed to newKey, false if newKey already exists
1.0.0
[[scredis.exceptions.RedisErrorResponseException]]
if the source and destination keys are the same, or when key does not exist
Creates a key using the provided serialized value, previously obtained using DUMP.
Creates a key using the provided serialized value, previously obtained using DUMP.
destination key
serialized value, previously obtained using DUMP
optional time-to-live duration of newly created key (expire)
2.6.0
[[scredis.exceptions.RedisErrorResponseException]]
if the value could not be restored
Incrementally iterates the set of keys in the currently selected Redis database.
Incrementally iterates the set of keys in the currently selected Redis database.
the offset
when defined, the command only returns elements matching the pattern
when defined, provides a hint of how many elements should be returned
a pair containing the next cursor as its first element and the set of keys as its second element
2.8.0
Sorts the elements of a list, set or sorted set.
Sorts the elements of a list, set or sorted set.
key of list, set or sorted set to be sorted
optional pattern for sorting by external values, can also be "nosort" if the sorting operation should be skipped (useful when only sorting to retrieve objects with get). The * gets replaced by the values of the elements in the collection
optional pair of numbers (offset, count) where offset specified the number of elements to skip and count specifies the number of elements to return starting from offset
list of patterns for retrieving objects stored in external keys. The * gets replaced by the values of the elements in the collection
indicates whether elements should be sorted descendingly
indicates whether elements should be sorted lexicographically
the sorted list of elements, or the empty list if the key does not exist
1.0.0
[[scredis.exceptions.RedisErrorResponseException]]
whenever an error occurs
Sorts the elements of a list, set or sorted set and then store the result.
Sorts the elements of a list, set or sorted set and then store the result.
key of list, set or sorted set to be sorted
key of list, set or sorted set to be sorted
optional pattern for sorting by external values, can also be "nosort" if the sorting operation should be skipped (useful when only sorting to retrieve objects with get). The * gets replaced by the values of the elements in the collection
optional pair of numbers (offset, count) where offset specified the number of elements to skip and count specifies the number of elements to return starting from offset
list of patterns for retrieving objects stored in external keys. The * gets replaced by the values of the elements in the collection
indicates whether elements should be sorted descendingly
indicates whether elements should be sorted lexicographically
the number of elements in the newly stored sorted collection
1.0.0
[[scredis.exceptions.RedisErrorResponseException]]
whenever an error occurs
Gets the time to live for a key in seconds.
Gets the time to live for a key in seconds.
result match { case Left(false) => // key does not exist case Left(true) => // key exists but has no associated expire case Right(ttl) => }
the target key
Right(ttl)
where ttl is the time-to-live in seconds for specified key,
Left(false)
if key does not exist or Left(true)
if key exists but has no associated
expire
1.0.0
For Redis
version <= 2.8.x, Left(false)
will be returned when the key does not
exists and when it exists but has no associated expire (Redis
returns the same error code
for both cases). In other words, you can simply check the following
result match { case Left(_) => case Right(ttl) => }
Determine the type stored at key.
Determine the type stored at key.
key for which the type should be returned
type of key, or None
if key does not exist
1.0.0
This method needs to be called as follows:
client.`type`(key)
This trait implements key commands.