RedisClient

public protocol RedisClient

An object capable of sending commands and receiving responses.

let client = ...
let result = client.send(command: "GET", arguments: ["my_key"])
// result == EventLoopFuture<RESPValue>

See https://redis.io/commands

  • The EventLoop that this client operates on.

    Declaration

    Swift

    var eventLoop: EventLoop { get }
  • Sends the desired command with the specified arguments.

    Declaration

    Swift

    func send(command: String, with arguments: [RESPValue]) -> EventLoopFuture<RESPValue>

    Parameters

    command

    The command to execute.

    arguments

    The arguments, if any, to be sent with the command.

    Return Value

    An EventLoopFuture that will resolve with the Redis command response.

  • echo(_:) Extension method

    Echos the provided message through the Redis instance.

    See https://redis.io/commands/echo

    Declaration

    Swift

    @inlinable
    public func echo(_ message: String) -> EventLoopFuture<String>

    Parameters

    message

    The message to echo.

    Return Value

    The message sent with the command.

  • ping(with:) Extension method

    Pings the server, which will respond with a message.

    See https://redis.io/commands/ping

    Declaration

    Swift

    @inlinable
    public func ping(with message: String? = nil) -> EventLoopFuture<String>

    Parameters

    message

    The optional message that the server should respond with.

    Return Value

    The provided message or Redis’ default response of "PONG".

  • select(database:) Extension method

    Select the Redis logical database having the specified zero-based numeric index.

    Note

    New connections always use the database 0.

    https://redis.io/commands/select

    Declaration

    Swift

    @inlinable
    public func select(database index: Int) -> EventLoopFuture<Void>

    Parameters

    index

    The 0-based index of the database that will receive later commands.

    Return Value

    An EventLoopFuture that resolves when the operation has succeeded, or fails with a RedisError.

  • swapDatabase(_:with:) Extension method

    Swaps the data of two Redis databases by their index IDs.

    See https://redis.io/commands/swapdb

    Declaration

    Swift

    @inlinable
    public func swapDatabase(_ first: Int, with second: Int) -> EventLoopFuture<Bool>

    Parameters

    first

    The index of the first database.

    second

    The index of the second database.

    Return Value

    true if the swap was successful.

  • delete(_:) Extension method

    Removes the specified keys. A key is ignored if it does not exist.

    https://redis.io/commands/del

    Declaration

    Swift

    @inlinable
    public func delete(_ keys: [String]) -> EventLoopFuture<Int>

    Parameters

    keys

    A list of keys to delete from the database.

    Return Value

    The number of keys deleted from the database.

  • delete(_:) Extension method

    Removes the specified keys. A key is ignored if it does not exist.

    https://redis.io/commands/del

    Declaration

    Swift

    @inlinable
    public func delete(_ keys: String...) -> EventLoopFuture<Int>

    Parameters

    keys

    A list of keys to delete from the database.

    Return Value

    The number of keys deleted from the database.

  • expire(_:after:) Extension method

    Sets a timeout on key. After the timeout has expired, the key will automatically be deleted.

    Note

    A key with an associated timeout is often said to be volatile in Redis terminology.

    https://redis.io/commands/expire

    Declaration

    Swift

    @inlinable
    public func expire(_ key: String, after timeout: TimeAmount) -> EventLoopFuture<Bool>

    Parameters

    key

    The key to set the expiration on.

    timeout

    The time from now the key will expire at.

    Return Value

    true if the expiration was set.

  • Incrementally iterates over all keys in the currently selected database.

    https://redis.io/commands/scan

    Declaration

    Swift

    @inlinable
    public func scan(
        startingFrom position: Int = 0,
        count: Int? = nil,
        matching match: String? = nil
    ) -> EventLoopFuture<(Int, [String])>

    Parameters

    position

    The cursor position to start from.

    count

    The number of elements to advance by. Redis default is 10.

    match

    A glob-style pattern to filter values to be selected from the result set.

    Return Value

    A cursor position for additional invocations with a limited collection of keys found in the database.

  • hdel(_:from:) Extension method

    Removes the specified fields from a hash.

    See https://redis.io/commands/hdel

    Declaration

    Swift

    @inlinable
    public func hdel(_ fields: [String], from key: String) -> EventLoopFuture<Int>

    Parameters

    fields

    The list of field names that should be removed from the hash.

    key

    The key of the hash to delete from.

    Return Value

    The number of fields that were deleted.

  • hdel(_:from:) Extension method

    Removes the specified fields from a hash.

    See https://redis.io/commands/hdel

    Declaration

    Swift

    @inlinable
    public func hdel(_ fields: String..., from key: String) -> EventLoopFuture<Int>

    Parameters

    fields

    The list of field names that should be removed from the hash.

    key

    The key of the hash to delete from.

    Return Value

    The number of fields that were deleted.

  • hexists(_:in:) Extension method

    Checks if a hash contains the field specified.

    See https://redis.io/commands/hexists

    Declaration

    Swift

    @inlinable
    public func hexists(_ field: String, in key: String) -> EventLoopFuture<Bool>

    Parameters

    field

    The field name to look for.

    key

    The key of the hash to look within.

    Return Value

    true if the hash contains the field, false if either the key or field do not exist.

  • hlen(of:) Extension method

    Gets the number of fields contained in a hash.

    See https://redis.io/commands/hlen

    Declaration

    Swift

    @inlinable
    public func hlen(of key: String) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the hash to get field count of.

    Return Value

    The number of fields in the hash, or 0 if the key doesn’t exist.

  • hstrlen(of:in:) Extension method

    Gets the string length of a hash field’s value.

    See https://redis.io/commands/hstrlen

    Declaration

    Swift

    @inlinable
    public func hstrlen(of field: String, in key: String) -> EventLoopFuture<Int>

    Parameters

    field

    The field name whose value is being accessed.

    key

    The key of the hash.

    Return Value

    The string length of the hash field’s value, or 0 if the field or hash do not exist.

  • hkeys(in:) Extension method

    Gets all field names in a hash.

    See https://redis.io/commands/hkeys

    Declaration

    Swift

    @inlinable
    public func hkeys(in key: String) -> EventLoopFuture<[String]>

    Parameters

    key

    The key of the hash.

    Return Value

    A list of field names stored within the hash.

  • hvals(in:) Extension method

    Gets all values stored in a hash.

    See https://redis.io/commands/hvals

    Declaration

    Swift

    @inlinable
    public func hvals(in key: String) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the hash.

    Return Value

    A list of all values stored in a hash.

  • Incrementally iterates over all fields in a hash.

    https://redis.io/commands/scan

    Declaration

    Swift

    @inlinable
    public func hscan(
        _ key: String,
        startingFrom position: Int = 0,
        count: Int? = nil,
        matching match: String? = nil
    ) -> EventLoopFuture<(Int, [String: String])>

    Parameters

    key

    The key of the hash.

    position

    The position to start the scan from.

    count

    The number of elements to advance by. Redis default is 10.

    match

    A glob-style pattern to filter values to be selected from the result set.

    Return Value

    A cursor position for additional invocations with a limited collection of found fields and their values.

  • hset(_:to:in:) Extension method

    Sets a hash field to the value specified.

    Note

    If you do not want to overwrite existing values, use hsetnx(_:field:to:).

    See https://redis.io/commands/hset

    Declaration

    Swift

    @inlinable
    public func hset<Value: RESPValueConvertible>(
        _ field: String,
        to value: Value,
        in key: String
    ) -> EventLoopFuture<Bool>

    Parameters

    field

    The name of the field in the hash being set.

    value

    The value the hash field should be set to.

    key

    The key that holds the hash.

    Return Value

    true if the hash was created, false if it was updated.

  • hsetnx(_:to:in:) Extension method

    Sets a hash field to the value specified only if the field does not currently exist.

    Note

    If you do not care about overwriting existing values, use hset(_:field:to:).

    See https://redis.io/commands/hsetnx

    Declaration

    Swift

    @inlinable
    public func hsetnx<Value: RESPValueConvertible>(
        _ field: String,
        to value: Value,
        in key: String
    ) -> EventLoopFuture<Bool>

    Parameters

    field

    The name of the field in the hash being set.

    value

    The value the hash field should be set to.

    key

    The key that holds the hash.

    Return Value

    true if the hash was created.

  • hmset(_:in:) Extension method

    Sets the fields in a hash to the respective values provided.

    See https://redis.io/commands/hmset

    Declaration

    Swift

    @inlinable
    public func hmset<Value: RESPValueConvertible>(
        _ fields: [String: Value],
        in key: String
    ) -> EventLoopFuture<Void>

    Parameters

    fields

    The key-value pair of field names and their respective values to set.

    key

    The key that holds the hash.

    Return Value

    An EventLoopFuture that resolves when the operation has succeeded, or fails with a RedisError.

  • hget(_:from:) Extension method

    Gets a hash field’s value.

    See https://redis.io/commands/hget

    Declaration

    Swift

    @inlinable
    public func hget(_ field: String, from key: String) -> EventLoopFuture<String?>

    Parameters

    field

    The name of the field whose value is being accessed.

    key

    The key of the hash being accessed.

    Return Value

    The value of the hash field, or nil if either the key or field does not exist.

  • hmget(_:from:) Extension method

    Gets the values of a hash for the fields specified.

    See https://redis.io/commands/hmget

    Declaration

    Swift

    @inlinable
    public func hmget(_ fields: [String], from key: String) -> EventLoopFuture<[String?]>

    Parameters

    fields

    A list of field names to get values for.

    key

    The key of the hash being accessed.

    Return Value

    A list of values in the same order as the fields argument. Non-existent fields return nil values.

  • hmget(_:from:) Extension method

    Gets the values of a hash for the fields specified.

    See https://redis.io/commands/hmget

    Declaration

    Swift

    @inlinable
    public func hmget(_ fields: String..., from key: String) -> EventLoopFuture<[String?]>

    Parameters

    fields

    A list of field names to get values for.

    key

    The key of the hash being accessed.

    Return Value

    A list of values in the same order as the fields argument. Non-existent fields return nil values.

  • hgetall(from:) Extension method

    Returns all the fields and values stored in a hash.

    See https://redis.io/commands/hgetall

    Declaration

    Swift

    @inlinable
    public func hgetall(from key: String) -> EventLoopFuture<[String : String]>

    Parameters

    key

    The key of the hash to pull from.

    Return Value

    A key-value pair list of fields and their values.

  • hincrby(_:field:in:) Extension method

    Increments a hash field’s value and returns the new value.

    See https://redis.io/commands/hincrby

    Declaration

    Swift

    @inlinable
    public func hincrby(_ amount: Int, field: String, in key: String) -> EventLoopFuture<Int>

    Parameters

    amount

    The amount to increment the value stored in the field by.

    field

    The name of the field whose value should be incremented.

    key

    The key of the hash the field is stored in.

    Return Value

    The new value of the hash field.

  • hincrbyfloat(_:field:in:) Extension method

    Increments a hash field’s value and returns the new value.

    See https://redis.io/commands/hincrbyfloat

    Declaration

    Swift

    @inlinable
    public func hincrbyfloat<Value>(_ amount: Value, field: String, in key: String) -> EventLoopFuture<Value>
        where
        Value: BinaryFloatingPoint,
        Value: RESPValueConvertible

    Parameters

    amount

    The amount to increment the value stored in the field by.

    field

    The name of the field whose value should be incremented.

    key

    The key of the hash the field is stored in.

    Return Value

    The new value of the hash field.

  • llen(of:) Extension method

    Gets the length of a list.

    See https://redis.io/commands/llen

    Declaration

    Swift

    @inlinable
    public func llen(of key: String) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the list.

    Return Value

    The number of elements in the list.

  • lindex(_:from:) Extension method

    Gets the element from a list stored at the provided index position.

    See https://redis.io/commands/lindex

    Declaration

    Swift

    @inlinable
    public func lindex(_ index: Int, from key: String) -> EventLoopFuture<RESPValue>

    Parameters

    index

    The 0-based index of the element to get.

    key

    The key of the list.

    Return Value

    The element stored at index, or .null if out of bounds.

  • lset(index:to:in:) Extension method

    Sets the value of an element in a list at the provided index position.

    See https://redis.io/commands/lset

    Declaration

    Swift

    @inlinable
    public func lset<Value: RESPValueConvertible>(
        index: Int,
        to value: Value,
        in key: String
    ) -> EventLoopFuture<Void>

    Parameters

    index

    The 0-based index of the element to set.

    value

    The new value the element should be.

    key

    The key of the list to update.

    Return Value

    An EventLoopFuture that resolves when the operation has succeeded, or fails with a RedisError.

  • lrem(_:from:count:) Extension method

    Removes elements from a list matching the value provided.

    See https://redis.io/commands/lrem

    Declaration

    Swift

    @inlinable
    public func lrem<Value: RESPValueConvertible>(
        _ value: Value,
        from key: String,
        count: Int = 0
    ) -> EventLoopFuture<Int>

    Parameters

    value

    The value to delete from the list.

    key

    The key of the list to remove from.

    count

    The max number of elements to remove matching the value. See Redis’ documentation for more info.

    Return Value

    The number of elements removed from the list.

  • ltrim(_:before:after:) Extension method

    Trims a list to only contain elements within the specified inclusive bounds of 0-based indices.

    See https://redis.io/commands/ltrim

    Declaration

    Swift

    @inlinable
    public func ltrim(_ key: String, before start: Int, after stop: Int) -> EventLoopFuture<Void>

    Parameters

    key

    The key of the list to trim.

    start

    The index of the first element to keep.

    stop

    The index of the last element to keep.

    Return Value

    An EventLoopFuture that resolves when the operation has succeeded, or fails with a RedisError.

  • lrange(within:from:) Extension method

    Gets all elements from a list within the the specified inclusive bounds of 0-based indices.

    See https://redis.io/commands/lrange

    Declaration

    Swift

    @inlinable
    public func lrange(
        within range: (startIndex: Int, endIndex: Int),
        from key: String
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    range

    The range of inclusive indices of elements to get.

    key

    The key of the list.

    Return Value

    A list of elements found within the range specified.

  • rpoplpush(from:to:) Extension method

    Pops the last element from a source list and pushes it to a destination list.

    See https://redis.io/commands/rpoplpush

    Declaration

    Swift

    @inlinable
    public func rpoplpush(from source: String, to dest: String) -> EventLoopFuture<RESPValue>

    Parameters

    source

    The key of the list to pop from.

    dest

    The key of the list to push to.

    Return Value

    The element that was moved.

  • brpoplpush(from:to:timeout:) Extension method

    Pops the last element from a source list and pushes it to a destination list, blocking until an element is available from the source list.

    Important

    This will block the connection from completing further commands until an element is available to pop from the source list.

    It is highly recommended to set a reasonable timeout or to use the non-blocking rpoplpush method where possible.

    See https://redis.io/commands/brpoplpush

    Declaration

    Swift

    @inlinable
    public func brpoplpush(
        from source: String,
        to dest: String,
        timeout: Int = 0
    ) -> EventLoopFuture<RESPValue?>

    Parameters

    source

    The key of the list to pop from.

    dest

    The key of the list to push to.

    timeout

    The time (in seconds) to wait. 0 means indefinitely.

    Return Value

    The element popped from the source list and pushed to the destination, or nil if the timeout was reached.

  • linsert(_:into:before:) Extension method

    Inserts the element before the first element matching the pivot value specified.

    See https://redis.io/commands/linsert

    Declaration

    Swift

    @inlinable
    public func linsert<Value: RESPValueConvertible>(
        _ element: Value,
        into key: String,
        before pivot: Value
    ) -> EventLoopFuture<Int>

    Parameters

    element

    The value to insert into the list.

    key

    The key of the list.

    pivot

    The value of the element to insert before.

    Return Value

    The size of the list after the insert, or -1 if an element matching the pivot value was not found.

  • linsert(_:into:after:) Extension method

    Inserts the element after the first element matching the pivot value provided.

    See https://redis.io/commands/linsert

    Declaration

    Swift

    @inlinable
    public func linsert<Value: RESPValueConvertible>(
        _ element: Value,
        into key: String,
        after pivot: Value
    ) -> EventLoopFuture<Int>

    Parameters

    element

    The value to insert into the list.

    key

    The key of the list.

    pivot

    The value of the element to insert after.

    Return Value

    The size of the list after the insert, or -1 if an element matching the pivot value was not found.

  • lpop(from:) Extension method

    Removes the first element of a list.

    See https://redis.io/commands/lpop

    Declaration

    Swift

    @inlinable
    public func lpop(from key: String) -> EventLoopFuture<RESPValue>

    Parameters

    key

    The key of the list to pop from.

    Return Value

    The element that was popped from the list, or .null.

  • lpush(_:into:) Extension method

    Pushes all of the provided elements into a list.

    Note

    This inserts the elements at the head of the list; for the tail see rpush(_:into:).

    See https://redis.io/commands/lpush

    Declaration

    Swift

    @inlinable
    public func lpush<Value>(_ elements: [Value], into key: String) -> EventLoopFuture<Int> where Value : RESPValueConvertible

    Parameters

    elements

    The values to push into the list.

    key

    The key of the list.

    Return Value

    The length of the list after adding the new elements.

  • lpush(_:into:) Extension method

    Pushes all of the provided elements into a list.

    Note

    This inserts the elements at the head of the list; for the tail see rpush(_:into:).

    See https://redis.io/commands/lpush

    Declaration

    Swift

    @inlinable
    public func lpush<Value>(_ elements: Value..., into key: String) -> EventLoopFuture<Int> where Value : RESPValueConvertible

    Parameters

    elements

    The values to push into the list.

    key

    The key of the list.

    Return Value

    The length of the list after adding the new elements.

  • lpushx(_:into:) Extension method

    Pushes an element into a list, but only if the key exists and holds a list.

    Note

    This inserts the element at the head of the list, for the tail see rpushx(_:into:).

    See https://redis.io/commands/lpushx

    Declaration

    Swift

    @inlinable
    public func lpushx<Value>(_ element: Value, into key: String) -> EventLoopFuture<Int> where Value : RESPValueConvertible

    Parameters

    element

    The value to try and push into the list.

    key

    The key of the list.

    Return Value

    The length of the list after adding the new elements.

  • rpop(from:) Extension method

    Removes the last element a list.

    See https://redis.io/commands/rpop

    Declaration

    Swift

    @inlinable
    public func rpop(from key: String) -> EventLoopFuture<RESPValue>

    Parameters

    key

    The key of the list to pop from.

    Return Value

    The element that was popped from the list, else .null.

  • rpush(_:into:) Extension method

    Pushes all of the provided elements into a list.

    Note

    This inserts the elements at the tail of the list; for the head see lpush(_:into:).

    See https://redis.io/commands/rpush - elements: The values to push into the list. - key: The key of the list.

    Declaration

    Swift

    @inlinable
    public func rpush<Value>(_ elements: [Value], into key: String) -> EventLoopFuture<Int> where Value : RESPValueConvertible

    Return Value

    The length of the list after adding the new elements.

  • rpush(_:into:) Extension method

    Pushes all of the provided elements into a list.

    Note

    This inserts the elements at the tail of the list; for the head see lpush(_:into:).

    See https://redis.io/commands/rpush - elements: The values to push into the list. - key: The key of the list.

    Declaration

    Swift

    @inlinable
    public func rpush<Value>(_ elements: Value..., into key: String) -> EventLoopFuture<Int> where Value : RESPValueConvertible

    Return Value

    The length of the list after adding the new elements.

  • rpushx(_:into:) Extension method

    Pushes an element into a list, but only if the key exists and holds a list.

    Note

    This inserts the element at the tail of the list; for the head see lpushx(_:into:).

    See https://redis.io/commands/rpushx

    Declaration

    Swift

    @inlinable
    public func rpushx<Value>(_ element: Value, into key: String) -> EventLoopFuture<Int> where Value : RESPValueConvertible

    Parameters

    element

    The value to try and push into the list.

    key

    The key of the list.

    Return Value

    The length of the list after adding the new elements.

  • blpop(from:timeout:) Extension method

    Removes the first element of a list, blocking until an element is available.

    Important

    This will block the connection from completing further commands until an element is available to pop from the list.

    It is highly recommended to set a reasonable timeout or to use the non-blocking lpop method where possible.

    See https://redis.io/commands/blpop

    Declaration

    Swift

    @inlinable
    public func blpop(from key: String, timeout: Int = 0) -> EventLoopFuture<RESPValue?>

    Parameters

    key

    The key of the list to pop from.

    Return Value

    The element that was popped from the list, or nil if the timout was reached.

  • blpop(from:timeout:) Extension method

    Removes the first element of a list, blocking until an element is available.

    Important

    This will block the connection from completing further commands until an element is available to pop from the group of lists.

    It is highly recommended to set a reasonable timeout or to use the non-blocking lpop method where possible.

    See https://redis.io/commands/blpop

    Declaration

    Swift

    @inlinable
    public func blpop(from keys: [String], timeout: Int = 0) -> EventLoopFuture<(String, RESPValue)?>

    Parameters

    keys

    The keys of lists in Redis that should be popped from.

    timeout

    The time (in seconds) to wait. 0 means indefinitely.

    Return Value

    If timeout was reached, nil.

    Otherwise, the key of the list the element was removed from and the popped element.

  • blpop(from:timeout:) Extension method

    Removes the first element of a list, blocking until an element is available.

    Important

    This will block the connection from completing further commands until an element is available to pop from the group of lists.

    It is highly recommended to set a reasonable timeout or to use the non-blocking lpop method where possible.

    See https://redis.io/commands/blpop

    Declaration

    Swift

    @inlinable
    public func blpop(from keys: String..., timeout: Int = 0) -> EventLoopFuture<(String, RESPValue)?>

    Parameters

    keys

    The keys of lists in Redis that should be popped from.

    timeout

    The time (in seconds) to wait. 0 means indefinitely.

    Return Value

    If timeout was reached, nil.

    Otherwise, the key of the list the element was removed from and the popped element.

  • brpop(from:timeout:) Extension method

    Removes the last element of a list, blocking until an element is available.

    Important

    This will block the connection from completing further commands until an element is available to pop from the list.

    It is highly recommended to set a reasonable timeout or to use the non-blocking rpop method where possible.

    See https://redis.io/commands/brpop

    Declaration

    Swift

    @inlinable
    public func brpop(from key: String, timeout: Int = 0) -> EventLoopFuture<RESPValue?>

    Parameters

    key

    The key of the list to pop from.

    Return Value

    The element that was popped from the list, or nil if the timout was reached.

  • brpop(from:timeout:) Extension method

    Removes the last element of a list, blocking until an element is available.

    Important

    This will block the connection from completing further commands until an element is available to pop from the group of lists.

    It is highly recommended to set a reasonable timeout or to use the non-blocking rpop method where possible.

    See https://redis.io/commands/brpop

    Declaration

    Swift

    @inlinable
    public func brpop(from keys: [String], timeout: Int = 0) -> EventLoopFuture<(String, RESPValue)?>

    Parameters

    keys

    The keys of lists in Redis that should be popped from.

    timeout

    The time (in seconds) to wait. 0 means indefinitely.

    Return Value

    If timeout was reached, nil.

    Otherwise, the key of the list the element was removed from and the popped element.

  • brpop(from:timeout:) Extension method

    Removes the last element of a list, blocking until an element is available.

    Important

    This will block the connection from completing further commands until an element is available to pop from the group of lists.

    It is highly recommended to set a reasonable timeout or to use the non-blocking rpop method where possible.

    See https://redis.io/commands/brpop

    Declaration

    Swift

    @inlinable
    public func brpop(from keys: String..., timeout: Int = 0) -> EventLoopFuture<(String, RESPValue)?>

    Parameters

    keys

    The keys of lists in Redis that should be popped from.

    timeout

    The time (in seconds) to wait. 0 means indefinitely.

    Return Value

    If timeout was reached, nil.

    Otherwise, the key of the list the element was removed from and the popped element.

  • smembers(of:) Extension method

    Gets all of the elements contained in a set.

    Note

    Ordering of results are stable between multiple calls of this method to the same set.

    Results are UNSTABLE in regards to the ordering of insertions through the sadd command and this method.

    See https://redis.io/commands/smembers

    Declaration

    Swift

    @inlinable
    public func smembers(of key: String) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the set.

    Return Value

    A list of elements found within the set.

  • sismember(_:of:) Extension method

    Checks if the element is included in a set.

    See https://redis.io/commands/sismember

    Declaration

    Swift

    @inlinable
    public func sismember<Value>(_ element: Value, of key: String) -> EventLoopFuture<Bool> where Value : RESPValueConvertible

    Parameters

    element

    The element to look for in the set.

    key

    The key of the set to look in.

    Return Value

    true if the element is in the set.

  • scard(of:) Extension method

    Gets the total count of elements within a set.

    See https://redis.io/commands/scard

    Declaration

    Swift

    @inlinable
    public func scard(of key: String) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the set.

    Return Value

    The total count of elements in the set.

  • sadd(_:to:) Extension method

    Adds elements to a set.

    See https://redis.io/commands/sadd

    Declaration

    Swift

    @inlinable
    public func sadd<Value>(_ elements: [Value], to key: String) -> EventLoopFuture<Int> where Value : RESPValueConvertible

    Parameters

    elements

    The values to add to the set.

    key

    The key of the set to insert into.

    Return Value

    The number of elements that were added to the set.

  • sadd(_:to:) Extension method

    Adds elements to a set.

    See https://redis.io/commands/sadd

    Declaration

    Swift

    @inlinable
    public func sadd<Value>(_ elements: Value..., to key: String) -> EventLoopFuture<Int> where Value : RESPValueConvertible

    Parameters

    elements

    The values to add to the set.

    key

    The key of the set to insert into.

    Return Value

    The number of elements that were added to the set.

  • srem(_:from:) Extension method

    Removes elements from a set.

    See https://redis.io/commands/srem

    Declaration

    Swift

    @inlinable
    public func srem<Value>(_ elements: [Value], from key: String) -> EventLoopFuture<Int> where Value : RESPValueConvertible

    Parameters

    elements

    The values to remove from the set.

    key

    The key of the set to remove from.

    Return Value

    The number of elements that were removed from the set.

  • srem(_:from:) Extension method

    Removes elements from a set.

    See https://redis.io/commands/srem

    Declaration

    Swift

    @inlinable
    public func srem<Value>(_ elements: Value..., from key: String) -> EventLoopFuture<Int> where Value : RESPValueConvertible

    Parameters

    elements

    The values to remove from the set.

    key

    The key of the set to remove from.

    Return Value

    The number of elements that were removed from the set.

  • spop(from:max:) Extension method

    Randomly selects and removes one or more elements in a set.

    See https://redis.io/commands/spop

    Declaration

    Swift

    @inlinable
    public func spop(from key: String, max count: Int = 1) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the set.

    count

    The max number of elements to pop from the set.

    Return Value

    The element that was popped from the set.

  • srandmember(from:max:) Extension method

    Randomly selects one or more elements in a set.

    connection.srandmember("my_key") // pulls just one random element
    connection.srandmember("my_key", max: -3) // pulls up to 3 elements, allowing duplicates
    connection.srandmember("my_key", max: 3) // pulls up to 3 elements, guaranteed unique
    

    See https://redis.io/commands/srandmember

    Declaration

    Swift

    @inlinable
    public func srandmember(from key: String, max count: Int = 1) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the set.

    count

    The max number of elements to select from the set.

    Return Value

    The elements randomly selected from the set.

  • smove(_:from:to:) Extension method

    Moves an element from one set to another.

    See https://redis.io/commands/smove

    Declaration

    Swift

    @inlinable
    public func smove<Value: RESPValueConvertible>(
        _ element: Value,
        from sourceKey: String,
        to destKey: String
    ) -> EventLoopFuture<Bool>

    Parameters

    element

    The value to move from the source.

    sourceKey

    The key of the source set.

    destKey

    The key of the destination set.

    Return Value

    true if the element was successfully removed from the source set.

  • Incrementally iterates over all values in a set.

    See https://redis.io/commands/sscan

    Declaration

    Swift

    @inlinable
    public func sscan(
        _ key: String,
        startingFrom position: Int = 0,
        count: Int? = nil,
        matching match: String? = nil
    ) -> EventLoopFuture<(Int, [RESPValue])>

    Parameters

    key

    The key of the set.

    position

    The position to start the scan from.

    count

    The number of elements to advance by. Redis default is 10.

    match

    A glob-style pattern to filter values to be selected from the result set.

    Return Value

    A cursor position for additional invocations with a limited collection of elements found in the set.

  • sdiff(of:) Extension method

    Calculates the difference between two or more sets.

    See https://redis.io/commands/sdiff

    Declaration

    Swift

    @inlinable
    public func sdiff(of keys: [String]) -> EventLoopFuture<[RESPValue]>

    Parameters

    keys

    The source sets to calculate the difference of.

    Return Value

    A list of elements resulting from the difference.

  • sdiff(of:) Extension method

    Calculates the difference between two or more sets.

    See https://redis.io/commands/sdiff

    Declaration

    Swift

    @inlinable
    public func sdiff(of keys: String...) -> EventLoopFuture<[RESPValue]>

    Parameters

    keys

    The source sets to calculate the difference of.

    Return Value

    A list of elements resulting from the difference.

  • sdiffstore(as:sources:) Extension method

    Calculates the difference between two or more sets and stores the result.

    Important

    If the destination key already exists, it is overwritten.

    See https://redis.io/commands/sdiffstore

    Declaration

    Swift

    @inlinable
    public func sdiffstore(as destination: String, sources keys: [String]) -> EventLoopFuture<Int>

    Parameters

    destination

    The key of the new set from the result.

    sources

    The list of source sets to calculate the difference of.

    Return Value

    The number of elements in the difference result.

  • sinter(of:) Extension method

    Calculates the intersection of two or more sets.

    See https://redis.io/commands/sinter

    Declaration

    Swift

    @inlinable
    public func sinter(of keys: [String]) -> EventLoopFuture<[RESPValue]>

    Parameters

    keys

    The source sets to calculate the intersection of.

    Return Value

    A list of elements resulting from the intersection.

  • sinter(of:) Extension method

    Calculates the intersection of two or more sets.

    See https://redis.io/commands/sinter

    Declaration

    Swift

    @inlinable
    public func sinter(of keys: String...) -> EventLoopFuture<[RESPValue]>

    Parameters

    keys

    The source sets to calculate the intersection of.

    Return Value

    A list of elements resulting from the intersection.

  • sinterstore(as:sources:) Extension method

    Calculates the intersetion of two or more sets and stores the result.

    Important

    If the destination key already exists, it is overwritten.

    See https://redis.io/commands/sinterstore

    Declaration

    Swift

    @inlinable
    public func sinterstore(as destination: String, sources keys: [String]) -> EventLoopFuture<Int>

    Parameters

    destination

    The key of the new set from the result.

    sources

    A list of source sets to calculate the intersection of.

    Return Value

    The number of elements in the intersection result.

  • sunion(of:) Extension method

    Calculates the union of two or more sets.

    See https://redis.io/commands/sunion

    Declaration

    Swift

    @inlinable
    public func sunion(of keys: [String]) -> EventLoopFuture<[RESPValue]>

    Parameters

    keys

    The source sets to calculate the union of.

    Return Value

    A list of elements resulting from the union.

  • sunion(of:) Extension method

    Calculates the union of two or more sets.

    See https://redis.io/commands/sunion

    Declaration

    Swift

    @inlinable
    public func sunion(of keys: String...) -> EventLoopFuture<[RESPValue]>

    Parameters

    keys

    The source sets to calculate the union of.

    Return Value

    A list of elements resulting from the union.

  • sunionstore(as:sources:) Extension method

    Calculates the union of two or more sets and stores the result.

    Important

    If the destination key already exists, it is overwritten.

    See https://redis.io/commands/sunionstore

    Declaration

    Swift

    @inlinable
    public func sunionstore(as destination: String, sources keys: [String]) -> EventLoopFuture<Int>

    Parameters

    destination

    The key of the new set from the result.

    sources

    A list of source sets to calculate the union of.

    Return Value

    The number of elements in the union result.

  • Adds elements to a sorted set, assigning their score to the values provided.

    Note

    INCR is not supported by this library in zadd. Use the zincrby(:element:in:) method instead.

    See https://redis.io/commands/zadd

    Declaration

    Swift

    @inlinable
    public func zadd<Value: RESPValueConvertible>(
        _ elements: [(element: Value, score: Double)],
        to key: String,
        option: RedisSortedSetAddOption? = nil,
        returnChangedCount: Bool = false
    ) -> EventLoopFuture<Int>

    Parameters

    elements

    A list of elements and their score to add to the sorted set.

    key

    The key of the sorted set.

    option

    An option for modifying the behavior of the command.

    returnChangedCount

    zadd normally returns the number of new elements added to the set, but setting this to true will instead have the command return the number of elements changed.

    Changed in this context are new elements added, and elements that had their score updated.

    Return Value

    The number of elements added to the sorted set, unless returnChangedCount was set to true.

  • Adds elements to a sorted set, assigning their score to the values provided.

    Note

    INCR is not supported by this library in zadd. Use the zincrby(:element:in:) method instead.

    See https://redis.io/commands/zadd

    Declaration

    Swift

    @inlinable
    public func zadd<Value: RESPValueConvertible>(
        _ elements: (element: Value, score: Double)...,
        to key: String,
        option: RedisSortedSetAddOption? = nil,
        returnChangedCount: Bool = false
    ) -> EventLoopFuture<Int>

    Parameters

    elements

    A list of elements and their score to add to the sorted set.

    key

    The key of the sorted set.

    option

    An option for modifying the behavior of the command.

    returnChangedCount

    zadd normally returns the number of new elements added to the set, but setting this to true will instead have the command return the number of elements changed.

    Changed in this context are new elements added, and elements that had their score updated.

    Return Value

    The number of elements added to the sorted set, unless returnChangedCount was set to true.

  • Adds an element to a sorted set, assigning their score to the value provided.

    See https://redis.io/commands/zadd

    Declaration

    Swift

    @inlinable
    public func zadd<Value: RESPValueConvertible>(
        _ element: (element: Value, score: Double),
        to key: String,
        option: RedisSortedSetAddOption? = nil,
        returnChangedCount: Bool = false
    ) -> EventLoopFuture<Bool>

    Parameters

    element

    The element and its score to add to the sorted set.

    key

    The key of the sorted set.

    option

    An option for modifying the behavior of the command.

    returnChangedCount

    zadd normally returns the number of new elements added to the set, but setting this to true will instead have the command return the number of elements changed.

    Changed in this context are new elements added, and elements that had their score updated.

    Return Value

    true if the element was added or score was updated in the sorted set, depending on the option and returnChangedCount settings set.

  • zcard(of:) Extension method

    Gets the number of elements in a sorted set.

    See https://redis.io/commands/zcard

    Declaration

    Swift

    @inlinable
    public func zcard(of key: String) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the sorted set.

    Return Value

    The number of elements in the sorted set.

  • zscore(of:in:) Extension method

    Gets the score of the specified element in a stored set.

    See https://redis.io/commands/zscore

    Declaration

    Swift

    @inlinable
    public func zscore<Value>(of element: Value, in key: String) -> EventLoopFuture<Double?> where Value : RESPValueConvertible

    Parameters

    element

    The element in the sorted set to get the score for.

    key

    The key of the sorted set.

    Return Value

    The score of the element provided, or nil if the element is not found in the set or the set does not exist.

  • Incrementally iterates over all elements in a sorted set.

    See https://redis.io/commands/zscan

    Declaration

    Swift

    @inlinable
    public func zscan(
        _ key: String,
        startingFrom position: Int = 0,
        count: Int? = nil,
        matching match: String? = nil
    ) -> EventLoopFuture<(Int, [(RESPValue, Double)])>

    Parameters

    key

    The key identifying the sorted set.

    position

    The position to start the scan from.

    count

    The number of elements to advance by. Redis default is 10.

    match

    A glob-style pattern to filter values to be selected from the result set.

    Return Value

    A cursor position for additional invocations with a limited collection of elements found in the sorted set with their scores.

  • zrank(of:in:) Extension method

    Returns the rank (index) of the specified element in a sorted set.

    Note

    This treats the ordered set as ordered from low to high. For the inverse, see zrevrank(of:in:).

    See https://redis.io/commands/zrank

    Declaration

    Swift

    @inlinable
    public func zrank<Value>(of element: Value, in key: String) -> EventLoopFuture<Int?> where Value : RESPValueConvertible

    Parameters

    element

    The element in the sorted set to search for.

    key

    The key of the sorted set to search.

    Return Value

    The index of the element, or nil if the key was not found.

  • zrevrank(of:in:) Extension method

    Returns the rank (index) of the specified element in a sorted set.

    Note

    This treats the ordered set as ordered from high to low. For the inverse, see zrank(of:in:).

    See https://redis.io/commands/zrevrank

    Declaration

    Swift

    @inlinable
    public func zrevrank<Value>(of element: Value, in key: String) -> EventLoopFuture<Int?> where Value : RESPValueConvertible

    Parameters

    element

    The element in the sorted set to search for.

    key

    The key of the sorted set to search.

    Return Value

    The index of the element, or nil if the key was not found.

  • zcount(of:within:) Extension method

    Returns the number of elements in a sorted set with a score within the range specified.

    See https://redis.io/commands/zcount

    Declaration

    Swift

    @inlinable
    public func zcount(
        of key: String,
        within range: (min: String, max: String)
    ) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the sorted set to count.

    range

    The min and max range of scores to filter for.

    Return Value

    The number of elements in the sorted set that fit within the score range.

  • zlexcount(of:within:) Extension method

    Returns the number of elements in a sorted set whose lexiographical values are between the range specified.

    Important

    This assumes all elements in the sorted set have the same score. If not, the returned elements are unspecified.

    See https://redis.io/commands/zlexcount

    Declaration

    Swift

    @inlinable
    public func zlexcount(
        of key: String,
        within range: (min: String, max: String)
    ) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the sorted set to count.

    range

    The min and max range of values to filter for.

    Return Value

    The number of elements in the sorted set that fit within the value range.

  • zpopmin(from:max:) Extension method

    Removes elements from a sorted set with the lowest scores.

    See https://redis.io/commands/zpopmin

    Declaration

    Swift

    @inlinable
    public func zpopmin(from key: String, max count: Int) -> EventLoopFuture<[(RESPValue, Double)]>

    Parameters

    key

    The key identifying the sorted set in Redis.

    count

    The max number of elements to pop from the set.

    Return Value

    A list of elements popped from the sorted set with their associated score.

  • zpopmin(from:) Extension method

    Removes the element from a sorted set with the lowest score.

    See https://redis.io/commands/zpopmin

    Declaration

    Swift

    @inlinable
    public func zpopmin(from key: String) -> EventLoopFuture<(RESPValue, Double)?>

    Parameters

    key

    The key identifying the sorted set in Redis.

    Return Value

    The element and its associated score that was popped from the sorted set, or nil if set was empty.

  • zpopmax(from:max:) Extension method

    Removes elements from a sorted set with the highest scores.

    See https://redis.io/commands/zpopmax

    Declaration

    Swift

    @inlinable
    public func zpopmax(from key: String, max count: Int) -> EventLoopFuture<[(RESPValue, Double)]>

    Parameters

    key

    The key identifying the sorted set in Redis.

    count

    The max number of elements to pop from the set.

    Return Value

    A list of elements popped from the sorted set with their associated score.

  • zpopmax(from:) Extension method

    Removes the element from a sorted set with the highest score.

    See https://redis.io/commands/zpopmax

    Declaration

    Swift

    @inlinable
    public func zpopmax(from key: String) -> EventLoopFuture<(RESPValue, Double)?>

    Parameters

    key

    The key identifying the sorted set in Redis.

    Return Value

    The element and its associated score that was popped from the sorted set, or nil if set was empty.

  • bzpopmin(from:timeout:) Extension method

    Removes the element from a sorted set with the lowest score, blocking until an element is available.

    Important

    This will block the connection from completing further commands until an element is available to pop from the set.

    It is highly recommended to set a reasonable timeout or to use the non-blocking zpopmin method where possible.

    See https://redis.io/commands/bzpopmin

    Declaration

    Swift

    @inlinable
    public func bzpopmin(
        from key: String,
        timeout: Int = 0
    ) -> EventLoopFuture<(Double, RESPValue)?>

    Parameters

    key

    The key identifying the sorted set in Redis.

    timeout

    The time (in seconds) to wait. 0 means indefinitely.

    Return Value

    The element and its associated score that was popped from the sorted set, or nil if the timeout was reached.

  • bzpopmin(from:timeout:) Extension method

    Removes the element from a sorted set with the lowest score, blocking until an element is available.

    Important

    This will block the connection from completing further commands until an element is available to pop from the group of sets.

    It is highly recommended to set a reasonable timeout or to use the non-blocking zpopmin method where possible.

    See https://redis.io/commands/bzpopmin

    Declaration

    Swift

    @inlinable
    public func bzpopmin(
        from keys: [String],
        timeout: Int = 0
    ) -> EventLoopFuture<(String, Double, RESPValue)?>

    Parameters

    keys

    A list of sorted set keys in Redis.

    timeout

    The time (in seconds) to wait. 0 means indefinitely.

    Return Value

    If timeout was reached, nil.

    Otherwise, the key of the sorted set the element was removed from, the element itself, and its associated score is returned.

  • bzpopmax(from:timeout:) Extension method

    Removes the element from a sorted set with the highest score, blocking until an element is available.

    Important

    This will block the connection from completing further commands until an element is available to pop from the set.

    It is highly recommended to set a reasonable timeout or to use the non-blocking zpopmax method where possible.

    See https://redis.io/commands/bzpopmax

    Declaration

    Swift

    @inlinable
    public func bzpopmax(
        from key: String,
        timeout: Int = 0
    ) -> EventLoopFuture<(Double, RESPValue)?>

    Parameters

    key

    The key identifying the sorted set in Redis.

    timeout

    The time (in seconds) to wait. 0 means indefinitely.

    Return Value

    The element and its associated score that was popped from the sorted set, or nil if the timeout was reached.

  • bzpopmax(from:timeout:) Extension method

    Removes the element from a sorted set with the highest score, blocking until an element is available.

    Important

    This will block the connection from completing further commands until an element is available to pop from the group of sets.

    It is highly recommended to set a reasonable timeout or to use the non-blocking zpopmax method where possible.

    See https://redis.io/commands/bzpopmax

    Declaration

    Swift

    @inlinable
    public func bzpopmax(
        from keys: [String],
        timeout: Int = 0
    ) -> EventLoopFuture<(String, Double, RESPValue)?>

    Parameters

    keys

    A list of sorted set keys in Redis.

    timeout

    The time (in seconds) to wait. 0 means indefinitely.

    Return Value

    If timeout was reached, nil.

    Otherwise, the key of the sorted set the element was removed from, the element itself, and its associated score is returned.

  • zincrby(_:element:in:) Extension method

    Increments the score of the specified element in a sorted set.

    See https://redis.io/commands/zincrby

    Declaration

    Swift

    @inlinable
    public func zincrby<Value: RESPValueConvertible>(
        _ amount: Double,
        element: Value,
        in key: String
    ) -> EventLoopFuture<Double>

    Parameters

    amount

    The amount to increment this element’s score by.

    element

    The element to increment.

    key

    The key of the sorted set.

    Return Value

    The new score of the element.

  • Calculates the union of two or more sorted sets and stores the result.

    Note

    This operation overwrites any value stored at the destination key.

    See https://redis.io/commands/zunionstore

    Declaration

    Swift

    @inlinable
    public func zunionstore(
        as destination: String,
        sources: [String],
        weights: [Int]? = nil,
        aggregateMethod aggregate: RedisSortedSetAggregateMethod? = nil
    ) -> EventLoopFuture<Int>

    Parameters

    destination

    The key of the new sorted set from the result.

    sources

    The list of sorted set keys to treat as the source of the union.

    weights

    The multiplying factor to apply to the corresponding sources key based on index of the two parameters.

    aggregateMethod

    The method of aggregating the values of the union. If one isn’t specified, Redis will default to .sum.

    Return Value

    The number of elements in the new sorted set.

  • Calculates the intersection of two or more sorted sets and stores the result.

    Note

    This operation overwrites any value stored at the destination key.

    See https://redis.io/commands/zinterstore

    Declaration

    Swift

    @inlinable
    public func zinterstore(
        as destination: String,
        sources: [String],
        weights: [Int]? = nil,
        aggregateMethod aggregate: RedisSortedSetAggregateMethod? = nil
    ) -> EventLoopFuture<Int>

    Parameters

    destination

    The key of the new sorted set from the result.

    sources

    The list of sorted set keys to treat as the source of the intersection.

    weights

    The multiplying factor to apply to the corresponding sources key based on index of the two parameters.

    aggregateMethod

    The method of aggregating the values of the intersection. If one isn’t specified, Redis will default to .sum.

    Return Value

    The number of elements in the new sorted set.

  • Gets the specified range of elements in a sorted set.

    Note

    This treats the ordered set as ordered from low to high.

    For the inverse, see zrevrange(within:from:withScores:).

    See https://redis.io/commands/zrange

    Declaration

    Swift

    @inlinable
    public func zrange(
        within range: (start: Int, stop: Int),
        from key: String,
        withScores: Bool = false
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    range

    The start and stop 0-based indices of the range of elements to include.

    key

    The key of the sorted set to search.

    withScores

    Should the list contain the elements AND their scores? [Item_1, Score_1, Item_2, …]

    Return Value

    A list of elements from the sorted set that were within the range provided, and optionally their scores.

  • Gets the specified range of elements in a sorted set.

    Note

    This treats the ordered set as ordered from high to low.

    For the inverse, see zrange(within:from:withScores:).

    See https://redis.io/commands/zrevrange

    Declaration

    Swift

    @inlinable
    public func zrevrange(
        within range: (start: Int, stop: Int),
        from key: String,
        withScores: Bool = false
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    range

    The start and stop 0-based indices of the range of elements to include.

    key

    The key of the sorted set to search.

    withScores

    Should the list contain the elements AND their scores? [Item_1, Score_1, Item_2, …]

    Return Value

    A list of elements from the sorted set that were within the range provided, and optionally their scores.

  • Gets elements from a sorted set whose score fits within the range specified.

    Note

    This treats the ordered set as ordered from low to high.

    For the inverse, see zrevrangebyscore(within:from:withScores:limitBy:).

    See https://redis.io/commands/zrangebyscore

    Declaration

    Swift

    @inlinable
    public func zrangebyscore(
        within range: (min: String, max: String),
        from key: String,
        withScores: Bool = false,
        limitBy limit: (offset: Int, count: Int)? = nil
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    range

    The range of min and max scores to filter elements by.

    key

    The key of the sorted set to search.

    withScores

    Should the list contain the elements AND their scores? [Item_1, Score_1, Item_2, …]

    limit

    The optional offset and count of elements to query.

    Return Value

    A list of elements from the sorted set that were within the range provided, and optionally their scores.

  • Gets elements from a sorted set whose score fits within the range specified.

    Note

    This treats the ordered set as ordered from high to low.

    For the inverse, see zrangebyscore(within:from:withScores:limitBy:).

    See https://redis.io/commands/zrevrangebyscore

    Declaration

    Swift

    @inlinable
    public func zrevrangebyscore(
        within range: (min: String, max: String),
        from key: String,
        withScores: Bool = false,
        limitBy limit: (offset: Int, count: Int)? = nil
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    range

    The range of min and max scores to filter elements by.

    key

    The key of the sorted set to search.

    withScores

    Should the list contain the elements AND their scores? [Item_1, Score_1, Item_2, …]

    limit

    The optional offset and count of elements to query.

    Return Value

    A list of elements from the sorted set that were within the range provided, and optionally their scores.

  • Gets elements from a sorted set whose lexiographical values are between the range specified.

    Important

    This assumes all elements in the sorted set have the same score. If not, the returned elements are unspecified.

    Note

    This treats the ordered set as ordered from low to high.

    For the inverse, see zrevrangebylex(within:from:limitBy:).

    See https://redis.io/commands/zrangebylex

    Declaration

    Swift

    @inlinable
    public func zrangebylex(
        within range: (min: String, max: String),
        from key: String,
        limitBy limit: (offset: Int, count: Int)? = nil
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    range

    The value range to filter elements by.

    key

    The key of the sorted set to search.

    limit

    The optional offset and count of elements to query.

    Return Value

    A list of elements from the sorted set that were within the range provided.

  • Gets elements from a sorted set whose lexiographical values are between the range specified.

    Important

    This assumes all elements in the sorted set have the same score. If not, the returned elements are unspecified.

    Note

    This treats the ordered set as ordered from high to low.

    For the inverse, see zrangebylex(within:from:limitBy:).

    See https://redis.io/commands/zrevrangebylex

    Declaration

    Swift

    @inlinable
    public func zrevrangebylex(
        within range: (min: String, max: String),
        from key: String,
        limitBy limit: (offset: Int, count: Int)? = nil
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    range

    The value range to filter elements by.

    key

    The key of the sorted set to search.

    limit

    The optional offset and count of elements to query.

    Return Value

    A list of elements from the sorted set that were within the range provided.

  • zrem(_:from:) Extension method

    Removes the specified elements from a sorted set.

    See https://redis.io/commands/zrem

    Declaration

    Swift

    @inlinable
    public func zrem<Value>(_ elements: [Value], from key: String) -> EventLoopFuture<Int> where Value : RESPValueConvertible

    Parameters

    elements

    The values to remove from the sorted set.

    key

    The key of the sorted set.

    Return Value

    The number of elements removed from the set.

  • zrem(_:from:) Extension method

    Removes the specified elements from a sorted set.

    See https://redis.io/commands/zrem

    Declaration

    Swift

    @inlinable
    public func zrem<Value>(_ elements: Value..., from key: String) -> EventLoopFuture<Int> where Value : RESPValueConvertible

    Parameters

    elements

    The values to remove from the sorted set.

    key

    The key of the sorted set.

    Return Value

    The number of elements removed from the set.

  • zremrangebylex(within:from:) Extension method

    Removes elements from a sorted set whose lexiographical values are between the range specified.

    Important

    This assumes all elements in the sorted set have the same score. If not, the elements selected are unspecified.

    See https://redis.io/commands/zremrangebylex

    Declaration

    Swift

    @inlinable
    public func zremrangebylex(
        within range: (min: String, max: String),
        from key: String
    ) -> EventLoopFuture<Int>

    Parameters

    range

    The value range to filter for elements to remove.

    key

    The key of the sorted set to search.

    Return Value

    The number of elements removed from the sorted set.

  • Removes elements from a sorted set whose index is between the provided range.

    See https://redis.io/commands/zremrangebyrank

    Declaration

    Swift

    @inlinable
    public func zremrangebyrank(
        within range: (start: Int, stop: Int),
        from key: String
    ) -> EventLoopFuture<Int>

    Parameters

    range

    The index range of elements to remove.

    key

    The key of the sorted set to search.

    Return Value

    The number of elements removed from the sorted set.

  • Removes elements from a sorted set whose score is within the range specified.

    See https://redis.io/commands/zremrangebyscore

    Declaration

    Swift

    @inlinable
    public func zremrangebyscore(
        within range: (min: String, max: String),
        from key: String
    ) -> EventLoopFuture<Int>

    Parameters

    range

    The score range to filter for elements to remove.

    key

    The key of the sorted set to search.

    Return Value

    The number of elements removed from the sorted set.

  • get(_:) Extension method

    Get the value of a key.

    https://redis.io/commands/get

    Declaration

    Swift

    @inlinable
    public func get(_ key: String) -> EventLoopFuture<String?>

    Parameters

    key

    The key to fetch the value from.

    Return Value

    The string value stored at the key provided, otherwise nil if the key does not exist.

  • get(_:as:) Extension method

    Get the value of a key, converting it to the desired type.

    https://redis.io/commands/get

    Declaration

    Swift

    @inlinable
    public func get<StoredType: RESPValueConvertible>(
        _ key: String,
        as type: StoredType.Type
    ) -> EventLoopFuture<StoredType?>

    Parameters

    key

    The key to fetch the value from.

    type

    The desired type to convert the stored data to.

    Return Value

    The converted value stored at the key provided, otherwise nil if the key does not exist or fails the conversion.

  • mget(_:) Extension method

    Gets the values of all specified keys, using .null to represent non-existant values.

    See https://redis.io/commands/mget

    Declaration

    Swift

    @inlinable
    public func mget(_ keys: [String]) -> EventLoopFuture<[RESPValue]>

    Parameters

    keys

    The list of keys to fetch the values from.

    Return Value

    The values stored at the keys provided, matching the same order.

  • mget(_:) Extension method

    Gets the values of all specified keys, using .null to represent non-existant values.

    See https://redis.io/commands/mget

    Declaration

    Swift

    @inlinable
    public func mget(_ keys: String...) -> EventLoopFuture<[RESPValue]>

    Parameters

    keys

    The list of keys to fetch the values from.

    Return Value

    The values stored at the keys provided, matching the same order.

  • append(_:to:) Extension method

    Append a value to the end of an existing entry.

    Note

    If the key does not exist, it is created and set as an empty string, so APPEND will be similar to SET in this special case.

    See https://redis.io/commands/append

    Declaration

    Swift

    @inlinable
    public func append<Value>(_ value: Value, to key: String) -> EventLoopFuture<Int> where Value : RESPValueConvertible

    Parameters

    value

    The value to append onto the value stored at the key.

    key

    The key to use to uniquely identify this value.

    Return Value

    The length of the key’s value after appending the additional value.

  • set(_:to:) Extension method

    Sets the value stored in the key provided, overwriting the previous value.

    Any previous expiration set on the key is discarded if the SET operation was successful.

    Important

    Regardless of the type of value stored at the key, it will be overwritten to a string value.

    https://redis.io/commands/set

    Declaration

    Swift

    @inlinable
    public func set<Value>(_ key: String, to value: Value) -> EventLoopFuture<Void> where Value : RESPValueConvertible

    Parameters

    key

    The key to use to uniquely identify this value.

    value

    The value to set the key to.

    Return Value

    An EventLoopFuture that resolves if the operation was successful.

  • mset(_:) Extension method

    Sets each key to their respective new value, overwriting existing values.

    Note

    Use msetnx(_:) if you don’t want to overwrite values.

    See https://redis.io/commands/mset

    Declaration

    Swift

    @inlinable
    public func mset<Value>(_ operations: [String : Value]) -> EventLoopFuture<Void> where Value : RESPValueConvertible

    Parameters

    operations

    The key-value list of SET operations to execute.

    Return Value

    An EventLoopFuture that resolves if the operation was successful.

  • msetnx(_:) Extension method

    Sets each key to their respective new value, only if all keys do not currently exist.

    Note

    Use mset(_:) if you don’t care about overwriting values.

    See https://redis.io/commands/msetnx

    Declaration

    Swift

    @inlinable
    public func msetnx<Value>(_ operations: [String : Value]) -> EventLoopFuture<Bool> where Value : RESPValueConvertible

    Parameters

    operations

    The key-value list of SET operations to execute.

    Return Value

    true if the operation successfully completed.

  • increment(_:) Extension method

    Increments the stored value by 1.

    See https://redis.io/commands/incr

    Declaration

    Swift

    @inlinable
    public func increment(_ key: String) -> EventLoopFuture<Int>

    Parameters

    key

    The key whose value should be incremented.

    Return Value

    The new value after the operation.

  • increment(_:by:) Extension method

    Increments the stored value by the amount desired .

    See https://redis.io/commands/incrby

    Declaration

    Swift

    @inlinable
    public func increment(_ key: String, by count: Int) -> EventLoopFuture<Int>

    Parameters

    key

    The key whose value should be incremented.

    count

    The amount that this value should be incremented, supporting both positive and negative values.

    Return Value

    The new value after the operation.

  • increment(_:by:) Extension method

    Increments the stored value by the amount desired.

    See https://redis.io/commands/incrbyfloat

    Declaration

    Swift

    @inlinable
    public func increment<Value>(_ key: String, by count: Value) -> EventLoopFuture<Value>
        where
        Value: BinaryFloatingPoint,
        Value: RESPValueConvertible

    Parameters

    key

    The key whose value should be incremented.

    count

    The amount that this value should be incremented, supporting both positive and negative values.

    Return Value

    The new value after the operation.

  • decrement(_:) Extension method

    Decrements the stored value by 1.

    See https://redis.io/commands/decr

    Declaration

    Swift

    @inlinable
    public func decrement(_ key: String) -> EventLoopFuture<Int>

    Parameters

    key

    The key whose value should be decremented.

    Return Value

    The new value after the operation.

  • decrement(_:by:) Extension method

    Decrements the stored valye by the amount desired.

    See https://redis.io/commands/decrby

    Declaration

    Swift

    public func decrement(_ key: String, by count: Int) -> EventLoopFuture<Int>

    Parameters

    key

    The key whose value should be decremented.

    count

    The amount that this value should be decremented, supporting both positive and negative values.

    Return Value

    The new value after the operation.

  • send(command:) Extension method

    Sends the desired command without arguments.

    Declaration

    Swift

    public func send(command: String) -> EventLoopFuture<RESPValue>

    Parameters

    command

    The command keyword to execute.

    Return Value

    An EventLoopFuture that will resolve with the Redis command response.