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>

For the full list of available commands, see https://redis.io/commands

  • The NIO.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

    A NIO.EventLoopFuture that will resolve with the Redis command response.

  • Temporarily overrides the default logger for command logs to the provided instance.

    Declaration

    Swift

    func logging(to logger: Logger) -> RedisClient

    Parameters

    logger

    The Logging.Logger instance to use for command logs.

    Return Value

    A RedisClient with the temporary override for command logging.

  • Subscribes the client to the specified Redis channels, invoking the provided message receiver each time a message is published.

    See SUBSCRIBE

    Important

    This will establish the client in a “PubSub mode” where only a specific list of commands are allowed to be executed.

    Commands issued with this client outside of that list will resolve with failures.

    See the PubSub specification

    Default Implementation

    Declaration

    Swift

    func subscribe(
        to channels: [RedisChannelName],
        messageReceiver receiver: @escaping RedisSubscriptionMessageReceiver,
        onSubscribe subscribeHandler: RedisSubscriptionChangeHandler?,
        onUnsubscribe unsubscribeHandler: RedisSubscriptionChangeHandler?
    ) -> EventLoopFuture<Void>

    Parameters

    channels

    The names of channels to subscribe to.

    receiver

    A closure which will be invoked each time a channel with a name in channels publishes a message.

    subscribeHandler

    An optional closure to be invoked when the subscription becomes active.

    unsubscribeHandler

    An optional closure to be invoked when the subscription becomes inactive.

    Return Value

    A notification NIO.EventLoopFuture that resolves once the subscription has been registered with Redis.

  • Subscribes the client to the specified Redis channel name patterns, invoking the provided message receiver each time a message is published to a matching channel.

    Note

    If the client is also subscribed to a channel directly by name which also matches a pattern, both subscription message receivers will be invoked.

    See PSUBSCRIBE

    Important

    This will establish the client in a “PubSub mode” where only a specific list of commands are allowed to be executed.

    Commands issues with this client outside of that list will resolve with failures.

    See the PubSub specification

    Default Implementation

    Declaration

    Swift

    func psubscribe(
        to patterns: [String],
        messageReceiver receiver: @escaping RedisSubscriptionMessageReceiver,
        onSubscribe subscribeHandler: RedisSubscriptionChangeHandler?,
        onUnsubscribe unsubscribeHandler: RedisSubscriptionChangeHandler?
    ) -> EventLoopFuture<Void>

    Parameters

    patterns

    A list of glob patterns used for matching against PubSub channel names to subscribe to.

    receiver

    A closure which will be invoked each time a channel with a name matching the specified pattern(s) publishes a message.

    subscribeHandler

    An optional closure to be invoked when the subscription becomes active.

    unsubscribeHandler

    An optional closure to be invoked when the subscription becomes inactive.

    Return Value

    A notification NIO.EventLoopFuture that resolves once the subscription has been registered with Redis.

  • unsubscribe(from:) Default implementation

    Unsubscribes the client from a specific Redis channel from receiving any future published messages.

    See UNSUBSCRIBE

    Note

    If the channel was not subscribed to with subscribe(to:messageReceiver:onSubscribe:onUnsubscribe:), then this method has no effect.

    Important

    If no more subscriptions (pattern or channel) are active on the client, the client will be taken out of its “PubSub mode”.

    It will then be allowed to use any command like normal.

    See the PubSub specification

    Default Implementation

    Declaration

    Swift

    func unsubscribe(from channels: [RedisChannelName]) -> EventLoopFuture<Void>

    Parameters

    channels

    A list of channel names to be unsubscribed from.

    Return Value

    A notification NIO.EventLoopFuture that resolves once the subscription(s) have been removed from Redis.

  • punsubscribe(from:) Default implementation

    Unsubscribes the client from a pattern of Redis channel names from receiving any future published messages.

    See PUNSUBSCRIBE

    Note

    This method does not unsubscribe subscriptions made with subscribe(to:messageReceiver:onSubscribe:onUnsubscribe:).

    Important

    If no more subscriptions (pattern or channel) are active on the client, the client will be taken out of its “PubSub mode”.

    It will then be allowed to use any command like normal.

    See the PubSub specification

    Default Implementation

    Declaration

    Swift

    func punsubscribe(from patterns: [String]) -> EventLoopFuture<Void>

    Parameters

    patterns

    A list of glob patterns to be unsubscribed from.

    Return Value

    A notification NIO.EventLoopFuture that resolves once the subscription(s) have been removed from Redis.

  • echo(_:) Extension method

    Echos the provided message through the Redis instance.

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

    Declaration

    Swift

    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

    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

    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

    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.

  • authorize(with:) Extension method

    Requests the client to authenticate with Redis to allow other commands to be executed.

    https://redis.io/commands/auth

    Declaration

    Swift

    public func authorize(with password: String) -> EventLoopFuture<Void>

    Parameters

    password

    The password to authenticate with.

    Return Value

    A NIO.EventLoopFuture that resolves if the password was accepted, otherwise it fails.

  • delete(_:) Extension method

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

    https://redis.io/commands/del

    Declaration

    Swift

    public func delete(_ keys: [RedisKey]) -> 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

    public func delete(_ keys: RedisKey...) -> EventLoopFuture<Int>

    Parameters

    keys

    A list of keys to delete from the database.

    Return Value

    The number of keys deleted from the database.

  • exists(_:) Extension method

    Checks the existence of the provided keys in the database.

    https://redis.io/commands/exists

    Declaration

    Swift

    public func exists(_ keys: [RedisKey]) -> EventLoopFuture<Int>

    Parameters

    keys

    A list of keys whose existence will be checked for in the database.

    Return Value

    The number of provided keys which exist in the database.

  • exists(_:) Extension method

    Checks the existence of the provided keys in the database.

    https://redis.io/commands/exists

    Declaration

    Swift

    public func exists(_ keys: RedisKey...) -> EventLoopFuture<Int>

    Parameters

    keys

    A list of keys whose existence will be checked for in the database.

    Return Value

    The number of provided keys which exist in 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

    public func expire(_ key: RedisKey, 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

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

    Parameters

    position

    The cursor position to start from.

    match

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

    count

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

    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

    public func hdel(_ fields: [String], from key: RedisKey) -> 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

    public func hdel(_ fields: String..., from key: RedisKey) -> 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

    public func hexists(_ field: String, in key: RedisKey) -> 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

    public func hlen(of key: RedisKey) -> 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

    public func hstrlen(of field: String, in key: RedisKey) -> 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

    public func hkeys(in key: RedisKey) -> 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

    public func hvals(in key: RedisKey) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the hash.

    Return Value

    A list of all values stored in a hash.

  • hvals(in:as:) Extension method

    Gets all values stored in a hash.

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

    Declaration

    Swift

    @inlinable
    public func hvals<Value>(in key: RedisKey, as type: Value.Type) -> EventLoopFuture<[Value?]> where Value : RESPValueConvertible

    Parameters

    key

    The key of the hash.

    type

    The type to convert the values to.

    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<Value: RESPValueConvertible>(
        _ key: RedisKey,
        startingFrom position: Int = 0,
        matching match: String? = nil,
        count: Int? = nil,
        valueType: Value.Type
    ) -> EventLoopFuture<(Int, [String: Value?])>

    Parameters

    key

    The key of the hash.

    position

    The position to start the scan from.

    match

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

    count

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

    valueType

    The type to cast all values to.

    Return Value

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

  • Incrementally iterates over all fields in a hash.

    https://redis.io/commands/scan

    Declaration

    Swift

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

    Parameters

    key

    The key of the hash.

    position

    The position to start the scan from.

    match

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

    count

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

    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: RedisKey
    ) -> 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: RedisKey
    ) -> 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: RedisKey
    ) -> 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

    public func hget(_ field: String, from key: RedisKey) -> EventLoopFuture<RESPValue>

    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. If the key or field does not exist, it will be .null.

  • hget(_:from:as:) Extension method

    Gets a hash field’s value as the desired type.

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

    Declaration

    Swift

    @inlinable
    public func hget<Value: RESPValueConvertible>(
        _ field: String,
        from key: RedisKey,
        as type: Value.Type
    ) -> EventLoopFuture<Value?>

    Parameters

    field

    The name of the field whose value is being accessed.

    key

    The key of the hash being accessed.

    type

    The type to convert the value to.

    Return Value

    The value of the hash field, or nil if the RESPValue conversion fails or 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

    public func hmget(_ fields: [String], from key: RedisKey) -> EventLoopFuture<[RESPValue]>

    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 .null values.

  • hmget(_:from:as:) Extension method

    Gets the values of a hash for the fields specified as a specific type.

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

    Declaration

    Swift

    @inlinable
    public func hmget<Value: RESPValueConvertible>(
        _ fields: [String],
        from key: RedisKey,
        as type: Value.Type
    ) -> EventLoopFuture<[Value?]>

    Parameters

    fields

    A list of field names to get values for.

    key

    The key of the hash being accessed.

    type

    The type to convert the values to.

    Return Value

    A list of values in the same order as the fields argument. Non-existent fields and elements that fail the RESPValue conversion 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

    public func hmget(_ fields: String..., from key: RedisKey) -> EventLoopFuture<[RESPValue]>

    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 .null values.

  • hmget(_:from:as:) Extension method

    Gets the values of a hash for the fields specified.

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

    Declaration

    Swift

    @inlinable
    public func hmget<Value: RESPValueConvertible>(
        _ fields: String...,
        from key: RedisKey,
        as type: Value.Type
    ) -> EventLoopFuture<[Value?]>

    Parameters

    fields

    A list of field names to get values for.

    key

    The key of the hash being accessed.

    type

    The type to convert the values to.

    Return Value

    A list of values in the same order as the fields argument. Non-existent fields and elements that fail the RESPValue conversion 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

    public func hgetall(from key: RedisKey) -> EventLoopFuture<[String : RESPValue]>

    Parameters

    key

    The key of the hash to pull from.

    Return Value

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

  • hgetall(from:as:) Extension method

    Returns all the fields and values stored in a hash.

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

    Declaration

    Swift

    @inlinable
    public func hgetall<Value: RESPValueConvertible>(
        from key: RedisKey,
        as type: Value.Type
    ) -> EventLoopFuture<[String: Value?]>

    Parameters

    key

    The key of the hash to pull from.

    type

    The type to convert the values to.

    Return Value

    A key-value pair list of fields and their values. Elements that fail the RESPValue conversion will be nil.

  • 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<Value: FixedWidthInteger & RESPValueConvertible>(
        _ amount: Value,
        field: String,
        in key: RedisKey
    ) -> EventLoopFuture<Value>

    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: BinaryFloatingPoint & RESPValueConvertible>(
        _ amount: Value,
        field: String,
        in key: RedisKey
    ) -> EventLoopFuture<Value>

    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

    public func llen(of key: RedisKey) -> 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

    public func lindex(_ index: Int, from key: RedisKey) -> 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.

  • lindex(_:from:as:) 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<Value: RESPValueConvertible>(
        _ index: Int,
        from key: RedisKey,
        as type: Value.Type
    ) -> EventLoopFuture<Value?>

    Parameters

    index

    The 0-based index of the element to get.

    key

    The key of the list.

    type

    The type to convert the value to.

    Return Value

    The element stored at index. If the value fails the RESPValue conversion or if the index is out of bounds, the returned value will be nil.

  • 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: RedisKey
    ) -> 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: RedisKey,
        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

    public func ltrim(_ key: RedisKey, 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

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

  • ltrim(_:keepingIndices:) Extension method

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

    To keep elements 4 through 7:

    client.ltrim("myList", keepingIndices: 3...6)
    

    To keep the last 4 through 7 elements:

    client.ltrim("myList", keepingIndices: (-7)...(-4))
    

    To keep the first and last 4 elements:

    client.ltrim("myList", keepingIndices: (-4)...3)
    

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

    Warning

    A ClosedRange cannot be created where upperBound is less than lowerBound; so while Redis may support 0...-1, ClosedRange will trigger a precondition failure.

    If you need such a range, use ltrim(_:before:after:) instead.

    Declaration

    Swift

    public func ltrim(_ key: RedisKey, keepingIndices range: ClosedRange<Int>) -> EventLoopFuture<Void>

    Parameters

    key

    The key of the List to trim.

    range

    The range of indices that should be kept in the List.

    Return Value

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

  • ltrim(_:keepingIndices:) Extension method

    Trims a List to only contain elements starting from the specified index.

    To keep all but the first 3 elements:

    client.ltrim("myList", keepingIndices: 3...)
    

    To keep the last 4 elements:

    client.ltrim("myList", keepingIndices: (-4)...)
    

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

    Declaration

    Swift

    public func ltrim(_ key: RedisKey, keepingIndices range: PartialRangeFrom<Int>) -> EventLoopFuture<Void>

    Parameters

    key

    The key of the List to trim.

    range

    The range of indices that should be kept in the List.

    Return Value

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

  • ltrim(_:keepingIndices:) Extension method

    Trims a List to only contain elements before the specified index.

    To keep the first 3 elements:

    client.ltrim("myList", keepingIndices: ..<3)
    

    To keep all but the last 4 elements:

    client.ltrim("myList", keepingIndices: ..<(-4))
    

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

    Declaration

    Swift

    public func ltrim(_ key: RedisKey, keepingIndices range: PartialRangeUpTo<Int>) -> EventLoopFuture<Void>

    Parameters

    key

    The key of the List to trim.

    range

    The range of indices that should be kept in the List.

    Return Value

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

  • ltrim(_:keepingIndices:) Extension method

    Trims a List to only contain elements up to the specified index.

    To keep the first 4 elements:

    client.ltrim("myList", keepingIndices: ...3)
    

    To keep all but the last 3 elements:

    client.ltrim("myList", keepingIndices: ...(-4))
    

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

    Declaration

    Swift

    public func ltrim(_ key: RedisKey, keepingIndices range: PartialRangeThrough<Int>) -> EventLoopFuture<Void>

    Parameters

    key

    The key of the List to trim.

    range

    The range of indices that should be kept in the List.

    Return Value

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

  • ltrim(_:keepingIndices:) Extension method

    Trims a List to only contain the elements from the specified index up to the index provided.

    To keep the first 4 elements:

    client.ltrim("myList", keepingIndices: 0..<4)
    

    To keep all but the last 3 elements:

    client.ltrim("myList", keepingIndices: 0..<(-3))
    

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

    Warning

    A Range cannot be created where upperBound is less than lowerBound; so while Redis may support 0..<(-1), Range will trigger a precondition failure.

    If you need such a range, use ltrim(_:before:after:) instead.

    Declaration

    Swift

    public func ltrim(_ key: RedisKey, keepingIndices range: Range<Int>) -> EventLoopFuture<Void>

    Parameters

    key

    The key of the List to trim.

    range

    The range of indices that should be kept in the List.

    Return Value

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

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

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

    Declaration

    Swift

    public func lrange(from key: RedisKey, firstIndex: Int, lastIndex: Int) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the List.

    firstIndex

    The index of the first element to include in the range of elements returned.

    lastIndex

    The index of the last element to include in the range of elements returned.

    Return Value

    An array of elements found within the range specified.

  • 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<Value: RESPValueConvertible>(
        from key: RedisKey,
        firstIndex: Int,
        lastIndex: Int,
        as type: Value.Type
    ) -> EventLoopFuture<[Value?]>

    Parameters

    key

    The key of the List.

    firstIndex

    The index of the first element to include in the range of elements returned.

    lastIndex

    The index of the last element to include in the range of elements returned.

    type

    The type to convert the values to.

    Return Value

    An array of elements found within the range specified, otherwise nil if the RESPValue conversion failed.

  • lrange(from:indices:) Extension method

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

    To get the elements at index 4 through 7:

    client.lrange(from: "myList", indices: 4...7)
    

    To get the last 4 elements:

    client.lrange(from: "myList", indices: (-4)...(-1))
    

    To get the first and last 4 elements:

    client.lrange(from: "myList", indices: (-4)...3)
    

    To get the first element, and the last 4:

    client.lrange(from: "myList", indices: (-4)...0))
    

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

    Warning

    A ClosedRange cannot be created where upperBound is less than lowerBound; so while Redis may support 0...-1, ClosedRange will trigger a precondition failure.

    If you need such a range, use lrange(from:firstIndex:lastIndex:) instead.

    Declaration

    Swift

    public func lrange(from key: RedisKey, indices range: ClosedRange<Int>) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the List to return elements from.

    range

    The range of inclusive indices of elements to get.

    Return Value

    An array of elements found within the range specified.

  • lrange(from:indices:as:) Extension method

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

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

    Warning

    A ClosedRange cannot be created where upperBound is less than lowerBound; so while Redis may support 0...-1, ClosedRange will trigger a precondition failure.

    If you need such a range, use lrange(from:firstIndex:lastIndex:) instead.

    Declaration

    Swift

    @inlinable
    public func lrange<Value: RESPValueConvertible>(
        from key: RedisKey,
        indices range: ClosedRange<Int>,
        as type: Value.Type
    ) -> EventLoopFuture<[Value?]>

    Parameters

    key

    The key of the List to return elements from.

    range

    The range of inclusive indices of elements to get.

    type

    The type to convert the values to.

    Return Value

    An array of elements found within the range specified, otherwise nil if the RESPValue conversion failed.

  • lrange(from:indices:) Extension method

    Gets all the elements from a List starting with the first index bound up to, but not including, the element at the last index bound.

    To get the elements at index 4 through 7:

    client.lrange(from: "myList", indices: 4..<8)
    

    To get the last 4 elements:

    client.lrange(from: "myList", indices: (-4)..<0)
    

    To get the first and last 4 elements:

    client.lrange(from: "myList", indices: (-4)..<4)
    

    To get the first element, and the last 4:

    client.lrange(from: "myList", indices: (-4)..<1)
    

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

    Warning

    A Range cannot be created where upperBound is less than lowerBound; so while Redis may support 0..<(-1), Range will trigger a precondition failure.

    If you need such a range, use lrange(from:firstIndex:lastIndex:) instead.

    Declaration

    Swift

    public func lrange(from key: RedisKey, indices range: Range<Int>) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the List to return elements from.

    range

    The range of indices (inclusive lower, exclusive upper) elements to get.

    Return Value

    An array of elements found within the range specified.

  • lrange(from:indices:as:) Extension method

    Gets all the elements from a List starting with the first index bound up to, but not including, the element at the last index bound.

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

    Warning

    A Range cannot be created where upperBound is less than lowerBound; so while Redis may support 0..<(-1), Range will trigger a precondition failure.

    If you need such a range, use lrange(from:firstIndex:lastIndex:) instead.

    Declaration

    Swift

    @inlinable
    public func lrange<Value: RESPValueConvertible>(
        from key: RedisKey,
        indices range: Range<Int>,
        as type: Value.Type
    ) -> EventLoopFuture<[Value?]>

    Parameters

    key

    The key of the List to return elements from.

    range

    The range of indices (inclusive lower, exclusive upper) elements to get.

    type

    The type to convert the values to.

    Return Value

    An array of elements found within the range specified, otherwise nil if the RESPValue conversion failed.

  • lrange(from:fromIndex:) Extension method

    Gets all elements from the index specified to the end of a List.

    To get all except the first 2 elements of a List:

    client.lrange(from: "myList", fromIndex: 2)
    

    To get the last 4 elements of a List:

    client.lrange(from: "myList", fromIndex: -4)
    

    See lrange(from:indices:), lrange(from:firstIndex:lastIndex:), and https://redis.io/commands/lrange

    Declaration

    Swift

    public func lrange(from key: RedisKey, fromIndex index: Int) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the List to return elements from.

    index

    The index of the first element that will be in the returned values.

    Return Value

    An array of elements from the List between the index and the end.

  • lrange(from:fromIndex:as:) Extension method

    Gets all elements from the index specified to the end of a List.

    See lrange(from:indices:), lrange(from:firstIndex:lastIndex:), and https://redis.io/commands/lrange

    Declaration

    Swift

    @inlinable
    public func lrange<Value: RESPValueConvertible>(
        from key: RedisKey,
        fromIndex index: Int,
        as type: Value.Type
    ) -> EventLoopFuture<[Value?]>

    Parameters

    key

    The key of the List to return elements from.

    index

    The index of the first element that will be in the returned values.

    type

    The type to convert the values to.

    Return Value

    An array of elements from the List between the index and the end, otherwise nil if the RESPValue conversion failed.

  • lrange(from:throughIndex:) Extension method

    Gets all elements from the the start of a List up to, and including, the element at the index specified.

    To get the first 3 elements of a List:

    client.lrange(from: "myList", throughIndex: 2)
    

    To get all except the last 3 elements of a List:

    client.lrange(from: "myList", throughIndex: -4)
    

    See lrange(from:indices:), lrange(from:firstIndex:lastIndex:), and https://redis.io/commands/lrange

    Declaration

    Swift

    public func lrange(from key: RedisKey, throughIndex index: Int) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the List to return elements from.

    index

    The index of the last element that will be in the returned values.

    Return Value

    An array of elements from the start of a List to the index.

  • Gets all elements from the the start of a List up to, and including, the element at the index specified.

    See lrange(from:indices:), lrange(from:firstIndex:lastIndex:), and https://redis.io/commands/lrange

    Declaration

    Swift

    @inlinable
    public func lrange<Value: RESPValueConvertible>(
        from key: RedisKey,
        throughIndex index: Int,
        as type: Value.Type
    ) -> EventLoopFuture<[Value?]>

    Parameters

    key

    The key of the List to return elements from.

    index

    The index of the last element that will be in the returned values.

    type

    The type to convert the values to.

    Return Value

    An array of elements from the start of a List to the index, otherwise nil if the RESPValue conversion failed.

  • lrange(from:upToIndex:) Extension method

    Gets all elements from the the start of a List up to, but not including, the element at the index specified.

    To get the first 3 elements of a List:

    client.lrange(from: "myList", upToIndex: 3)
    

    To get all except the last 3 elements of a List:

    client.lrange(from: "myList", upToIndex: -3)
    

    See lrange(from:indices:), lrange(from:firstIndex:lastIndex:), and https://redis.io/commands/lrange

    Declaration

    Swift

    public func lrange(from key: RedisKey, upToIndex index: Int) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the List to return elements from.

    index

    The index of the element to not include in the returned values.

    Return Value

    An array of elements from the start of the List and up to the index.

  • lrange(from:upToIndex:as:) Extension method

    Gets all elements from the the start of a List up to, but not including, the element at the index specified.

    See lrange(from:indices:), lrange(from:firstIndex:lastIndex:), and https://redis.io/commands/lrange

    Declaration

    Swift

    @inlinable
    public func lrange<Value: RESPValueConvertible>(
        from key: RedisKey,
        upToIndex index: Int,
        as type: Value.Type
    ) -> EventLoopFuture<[Value?]>

    Parameters

    key

    The key of the List to return elements from.

    index

    The index of the element to not include in the returned values.

    type

    The type to convert the values to.

    Return Value

    An array of elements from the start of the List and up to the index, otherwise nil if the RESPValue conversion failed.

  • 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

    public func rpoplpush(from source: RedisKey, to dest: RedisKey) -> 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.

  • 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<Value: RESPValueConvertible>(
        from source: RedisKey,
        to dest: RedisKey,
        valueType: Value.Type
    ) -> EventLoopFuture<Value?>

    Parameters

    source

    The key of the list to pop from.

    dest

    The key of the list to push to.

    type

    The type to convert the value to.

    Return Value

    The element that was moved. This value is nil if the RESPValue conversion failed.

  • 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

    public func brpoplpush(
        from source: RedisKey,
        to dest: RedisKey,
        timeout: TimeAmount = .seconds(0)
    ) -> EventLoopFuture<RESPValue>

    Parameters

    source

    The key of the list to pop from.

    dest

    The key of the list to push to.

    timeout

    The max time to wait for a value to use. 0 seconds means to wait indefinitely.

    Return Value

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

  • 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<Value: RESPValueConvertible>(
        from source: RedisKey,
        to dest: RedisKey,
        timeout: TimeAmount = .seconds(0),
        valueType: Value.Type
    ) -> EventLoopFuture<Value?>

    Parameters

    source

    The key of the list to pop from.

    dest

    The key of the list to push to.

    timeout

    The max time to wait for a value to use. 0 seconds means to wait indefinitely.

    type

    The type to convert the value to.

    Return Value

    The element popped from the source list and pushed to the destination. If the timeout was reached or RESPValue conversion failed, the returned value will be nil.

  • 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: RedisKey,
        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: RedisKey,
        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

    public func lpop(from key: RedisKey) -> EventLoopFuture<RESPValue>

    Parameters

    key

    The key of the list to pop from.

    Return Value

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

  • lpop(from:as:) Extension method

    Removes the first element of a list.

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

    Declaration

    Swift

    @inlinable
    public func lpop<Value>(from key: RedisKey, as type: Value.Type) -> EventLoopFuture<Value?> where Value : RESPValueConvertible

    Parameters

    key

    The key of the list to pop from.

    type

    The type to convert the value to.

    Return Value

    The element that was popped from the list. If the list is empty or the RESPValue conversion failed, this value is nil.

  • 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: RedisKey) -> 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: RedisKey) -> 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: RedisKey) -> 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

    public func blpop(from key: RedisKey, timeout: TimeAmount = .seconds(0)) -> EventLoopFuture<RESPValue>

    Parameters

    key

    The key of the list to pop from.

    timeout

    The max time to wait for a value to use. 0seconds means to wait indefinitely.

    Return Value

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

  • blpop(from:as: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<Value: RESPValueConvertible>(
        from key: RedisKey,
        as type: Value.Type,
        timeout: TimeAmount = .seconds(0)
    ) -> EventLoopFuture<Value?>

    Parameters

    key

    The key of the list to pop from.

    type

    The type to convert the value to.

    timeout

    The max time to wait for a value to use. 0seconds means to wait indefinitely.

    Return Value

    The element that was popped from the list. If the timeout was reached or RESPValue conversion failed, nil.

  • 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

    public func blpop(from keys: [RedisKey], timeout: TimeAmount = .seconds(0)) -> EventLoopFuture<(RedisKey, RESPValue)?>

    Parameters

    keys

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

    timeout

    The max time to wait for a value to use. 0seconds means to wait indefinitely.

    Return Value

    If timeout was reached, nil.

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

  • 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<Value: RESPValueConvertible>(
        from keys: [RedisKey],
        timeout: TimeAmount = .seconds(0),
        valueType: Value.Type
    ) -> EventLoopFuture<(RedisKey, Value)?>

    Parameters

    keys

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

    timeout

    The max time to wait for a value to use. 0seconds means to wait indefinitely.

    valueType

    The type to convert the value to.

    Return Value

    If timeout was reached or the RESPValue conversion failed, 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

    public func blpop(from keys: RedisKey..., timeout: TimeAmount = .seconds(0)) -> EventLoopFuture<(RedisKey, RESPValue)?>

    Parameters

    keys

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

    timeout

    The max time to wait for a value to use. 0seconds means to wait indefinitely.

    Return Value

    If timeout was reached, nil.

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

  • 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<Value: RESPValueConvertible>(
        from keys: RedisKey...,
        timeout: TimeAmount = .seconds(0),
        valueType: Value.Type
    ) -> EventLoopFuture<(RedisKey, Value)?>

    Parameters

    keys

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

    timeout

    The max time to wait for a value to use. 0seconds means to wait indefinitely.

    valueType

    The type to convert the value to.

    Return Value

    If timeout was reached or RESPValue conversion failed, 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

    public func brpop(from key: RedisKey, timeout: TimeAmount = .seconds(0)) -> EventLoopFuture<RESPValue>

    Parameters

    key

    The key of the list to pop from.

    timeout

    The max time to wait for a value to use. 0seconds means to wait indefinitely.

    Return Value

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

  • brpop(from:as: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<Value: RESPValueConvertible>(
        from key: RedisKey,
        as type: Value.Type,
        timeout: TimeAmount = .seconds(0)
    ) -> EventLoopFuture<Value?>

    Parameters

    key

    The key of the list to pop from.

    type

    The type to convert the value to.

    timeout

    The max time to wait for a value to use. 0seconds means to wait indefinitely.

    Return Value

    The element that was popped from the list. If the timeout was reached or the RESPValue conversion fails, this value is nil.

  • 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

    public func brpop(from keys: [RedisKey], timeout: TimeAmount = .seconds(0)) -> EventLoopFuture<(RedisKey, RESPValue)?>

    Parameters

    keys

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

    timeout

    The max time to wait for a value to use. 0seconds means to wait indefinitely.

    Return Value

    If timeout was reached, nil.

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

  • 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<Value: RESPValueConvertible>(
        from keys: [RedisKey],
        timeout: TimeAmount = .seconds(0),
        valueType: Value.Type
    ) -> EventLoopFuture<(RedisKey, Value)?>

    Parameters

    keys

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

    timeout

    The max time to wait for a value to use. 0seconds means to wait indefinitely.

    Return Value

    If timeout was reached or RESPValue conversion failed, 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

    public func brpop(from keys: RedisKey..., timeout: TimeAmount = .seconds(0)) -> EventLoopFuture<(RedisKey, RESPValue)?>

    Parameters

    keys

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

    timeout

    The max time to wait for a value to use. 0seconds means to wait indefinitely.

    Return Value

    If timeout was reached, nil.

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

  • 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<Value: RESPValueConvertible>(
        from keys: RedisKey...,
        timeout: TimeAmount = .seconds(0),
        valueType: Value.Type
    ) -> EventLoopFuture<(RedisKey, Value)?>

    Parameters

    keys

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

    timeout

    The max time to wait for a value to use. 0seconds means to wait indefinitely.

    Return Value

    If timeout was reached or RESPValue conversion failed, nil.

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

  • publish(_:to:) Extension method

    Publishes the provided message to a specific Redis channel.

    See PUBLISH

    Declaration

    Swift

    @discardableResult
    @inlinable
    public func publish<Message: RESPValueConvertible>(
        _ message: Message,
        to channel: RedisChannelName
    ) -> EventLoopFuture<Int>

    Parameters

    message

    The “message” value to publish on the channel.

    channel

    The name of the channel to publish the message to.

    Return Value

    The number of subscribed clients that received the message.

  • activeChannels(matching:) Extension method

    Resolves a list of all the channels that have at least 1 (non-pattern) subscriber.

    See PUBSUB CHANNELS

    Note

    If no match pattern is provided, all active channels will be returned.

    Declaration

    Swift

    public func activeChannels(matching match: String? = nil) -> EventLoopFuture<[RedisChannelName]>

    Parameters

    match

    An optional pattern of channel names to filter for.

    Return Value

    A list of all active channel names.

  • patternSubscriberCount() Extension method

    Resolves the total count of active subscriptions to channels that were made using patterns.

    See PUBSUB NUMPAT

    Declaration

    Swift

    public func patternSubscriberCount() -> EventLoopFuture<Int>

    Return Value

    The total count of subscriptions made through patterns.

  • Resolves a count of (non-pattern) subscribers for each given channel.

    See PUBSUB NUMSUB

    Declaration

    Swift

    public func subscriberCount(forChannels channels: [RedisChannelName]) -> EventLoopFuture<[RedisChannelName : Int]>

    Parameters

    channels

    A list of channel names to collect the subscriber counts for.

    Return Value

    A mapping of channel names and their (non-pattern) subscriber count.

  • 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

    public func smembers(of key: RedisKey) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the set.

    Return Value

    A list of elements found within the set.

  • smembers(of:as:) 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<Value>(of key: RedisKey, as type: Value.Type) -> EventLoopFuture<[Value?]> where Value : RESPValueConvertible

    Parameters

    key

    The key of the set.

    type

    The type to convert the values to.

    Return Value

    A list of elements found within the set. Elements that fail the RESPValue conversion will be nil.

  • 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: RedisKey) -> 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

    public func scard(of key: RedisKey) -> 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: RedisKey) -> 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: RedisKey) -> 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: RedisKey) -> 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: RedisKey) -> 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

    public func spop(from key: RedisKey, 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.

  • spop(from:as: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<Value: RESPValueConvertible>(
        from key: RedisKey,
        as type: Value.Type,
        max count: Int = 1
    ) -> EventLoopFuture<[Value?]>

    Parameters

    key

    The key of the set.

    type

    The type to convert the values to.

    count

    The max number of elements to pop from the set.

    Return Value

    The element that was popped from the set. Elements that fail the RESPValue conversion will be nil.

  • 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

    public func srandmember(from key: RedisKey, 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.

  • srandmember(from:as:max:) Extension method

    Randomly selects one or more elements in a set.

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

    Declaration

    Swift

    @inlinable
    public func srandmember<Value: RESPValueConvertible>(
        from key: RedisKey,
        as type: Value.Type,
        max count: Int = 1
    ) -> EventLoopFuture<[Value?]>

    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. Elements that fail the RESPValue conversion will be nil.

  • 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: RedisKey,
        to destKey: RedisKey
    ) -> 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

    public func sscan(
        _ key: RedisKey,
        startingFrom position: Int = 0,
        matching match: String? = nil,
        count: Int? = 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.

  • Incrementally iterates over all values in a set.

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

    Declaration

    Swift

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

    Parameters

    key

    The key of the set.

    position

    The position to start the scan from.

    match

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

    count

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

    valueType

    The type to convert the value to.

    Return Value

    A cursor position for additional invocations with a limited collection of elements found in the set. Elements that fail the RESPValue conversion will be nil.

  • sdiff(of:) Extension method

    Calculates the difference between two or more sets.

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

    Declaration

    Swift

    public func sdiff(of keys: [RedisKey]) -> EventLoopFuture<[RESPValue]>

    Parameters

    keys

    The source sets to calculate the difference of.

    Return Value

    A list of elements resulting from the difference.

  • sdiff(of:valueType:) Extension method

    Calculates the difference between two or more sets.

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

    Declaration

    Swift

    @inlinable
    public func sdiff<Value>(of keys: [RedisKey], valueType: Value.Type) -> EventLoopFuture<[Value?]> where Value : RESPValueConvertible

    Parameters

    keys

    The source sets to calculate the difference of.

    valueType

    The type to convert the values to.

    Return Value

    A list of elements resulting from the difference. Elements that fail the RESPValue conversion will be nil.

  • sdiff(of:) Extension method

    Calculates the difference between two or more sets.

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

    Declaration

    Swift

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

    Parameters

    keys

    The source sets to calculate the difference of.

    Return Value

    A list of elements resulting from the difference.

  • sdiff(of:valueType:) Extension method

    Calculates the difference between two or more sets.

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

    Declaration

    Swift

    @inlinable
    public func sdiff<Value>(of keys: RedisKey..., valueType: Value.Type) -> EventLoopFuture<[Value?]> where Value : RESPValueConvertible

    Parameters

    keys

    The source sets to calculate the difference of.

    valueType

    The type to convert the values to.

    Return Value

    A list of elements resulting from the difference. Elements that fail the RESPValue conversion will be nil.

  • 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

    public func sdiffstore(as destination: RedisKey, sources keys: [RedisKey]) -> 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

    public func sinter(of keys: [RedisKey]) -> EventLoopFuture<[RESPValue]>

    Parameters

    keys

    The source sets to calculate the intersection of.

    Return Value

    A list of elements resulting from the intersection.

  • sinter(of:valueType:) Extension method

    Calculates the intersection of two or more sets.

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

    Declaration

    Swift

    @inlinable
    public func sinter<Value>(of keys: [RedisKey], valueType: Value.Type) -> EventLoopFuture<[Value?]> where Value : RESPValueConvertible

    Parameters

    keys

    The source sets to calculate the intersection of.

    valueType

    The type to convert all values to.

    Return Value

    A list of elements resulting from the intersection. Elements that fail the RESPValue conversion will be nil.

  • sinter(of:) Extension method

    Calculates the intersection of two or more sets.

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

    Declaration

    Swift

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

    Parameters

    keys

    The source sets to calculate the intersection of.

    Return Value

    A list of elements resulting from the intersection.

  • sinter(of:valueType:) Extension method

    Calculates the intersection of two or more sets.

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

    Declaration

    Swift

    @inlinable
    public func sinter<Value>(of keys: RedisKey..., valueType: Value.Type) -> EventLoopFuture<[Value?]> where Value : RESPValueConvertible

    Parameters

    keys

    The source sets to calculate the intersection of.

    valueType

    The type to convert all values to.

    Return Value

    A list of elements resulting from the intersection. Elements that fail the RESPValue conversion will be nil.

  • 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

    public func sinterstore(as destination: RedisKey, sources keys: [RedisKey]) -> 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.

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

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

    Declaration

    Swift

    @inlinable
    public func zadd<Value: RESPValueConvertible>(
        _ elements: [(element: Value, score: Double)],
        to key: RedisKey,
        inserting insertBehavior: RedisZaddInsertBehavior = .allElements,
        returning returnBehavior: RedisZaddReturnBehavior = .insertedElementsCount
    ) -> EventLoopFuture<Int>

    Parameters

    elements

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

    key

    The key of the sorted set.

    insertBehavior

    The desired behavior of handling new and existing elements in the SortedSet.

    returnBehavior

    The desired behavior of what the return value should represent.

    Return Value

    If returning is .changedElementsCount, the number of elements inserted and that had their score updated. Otherwise, just the number of new elements inserted.

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

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

    Declaration

    Swift

    @inlinable
    public func zadd<Value: RESPValueConvertible>(
        _ elements: (element: Value, score: Double)...,
        to key: RedisKey,
        inserting insertBehavior: RedisZaddInsertBehavior = .allElements,
        returning returnBehavior: RedisZaddReturnBehavior = .insertedElementsCount
    ) -> EventLoopFuture<Int>

    Parameters

    elements

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

    key

    The key of the sorted set.

    insertBehavior

    The desired behavior of handling new and existing elements in the SortedSet.

    returnBehavior

    The desired behavior of what the return value should represent.

    Return Value

    If returning is .changedElementsCount, the number of elements inserted and that had their score updated. Otherwise, just the number of new elements inserted.

  • 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: RedisKey,
        inserting insertBehavior: RedisZaddInsertBehavior = .allElements,
        returning returnBehavior: RedisZaddReturnBehavior = .insertedElementsCount
    ) -> EventLoopFuture<Bool>

    Parameters

    element

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

    key

    The key of the sorted set.

    insertBehavior

    The desired behavior of handling new and existing elements in the SortedSet.

    returnBehavior

    The desired behavior of what the return value should represent.

    Return Value

    If returning is .changedElementsCount, the number of elements inserted and that had their score updated. Otherwise, just the number of new elements inserted.

  • zcard(of:) Extension method

    Gets the number of elements in a sorted set.

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

    Declaration

    Swift

    public func zcard(of key: RedisKey) -> 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: RedisKey) -> 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

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

    Parameters

    key

    The key identifying the sorted set.

    position

    The position to start the scan from.

    match

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

    count

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

    Return Value

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

  • Incrementally iterates over all elements in a sorted set.

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

    Declaration

    Swift

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

    Parameters

    key

    The key identifying the sorted set.

    position

    The position to start the scan from.

    match

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

    count

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

    valueType

    The type to convert the values to.

    Return Value

    A cursor position for additional invocations with a limited collection of elements found in the sorted set with their scores. Any element that fails the RESPValue conversion will be nil.

  • 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: RedisKey) -> 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: RedisKey) -> 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.

  • Returns the count of elements in a SortedSet with a score within the range specified (inclusive by default).

    To get a count of elements that have at least the score of 3, but no greater than 10:

    client.zcount(of: "mySortedSet", withScoresBetween: (3, 10))
    

    To get a count of elements that have at least the score of 3, but less than 10:

    client.zcount(of: "mySortedSet", withScoresBetween: (3, .exclusive(10)))
    

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

    Declaration

    Swift

    public func zcount(
        of key: RedisKey,
        withScoresBetween range: (min: RedisZScoreBound, max: RedisZScoreBound)
    ) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet that will be counted.

    range

    The min and max score bounds that an element should have in order to be counted.

    Return Value

    The count of elements in the SortedSet with a score matching the range specified.

  • zcount(of:withScores:) Extension method

    Returns the count of elements in a SortedSet with a score within the inclusive range specified.

    To get a count of elements that have at least the score of 3, but no greater than 10:

    client.zcount(of: "mySortedSet", withScores: 3...10)
    

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

    Declaration

    Swift

    public func zcount(of key: RedisKey, withScores range: ClosedRange<Double>) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet that will be counted.

    range

    The inclusive range of scores to filter elements to count.

    Return Value

    The count of elements in the SortedSet with a score within the range specified.

  • zcount(of:withScores:) Extension method

    Returns the count of elements in a SortedSet with a minimum score up to, but not including, a max score.

    To get a count of elements that have at least the score of 3, but less than 10:

    client.zcount(of: "mySortedSet", withScores: 3..<10)
    

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

    Declaration

    Swift

    public func zcount(of key: RedisKey, withScores range: Range<Double>) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet that will be counted.

    range

    A range with an inclusive lower and exclusive upper bound of scores to filter elements to count.

    Return Value

    The count of elements in the SortedSet with a score within the range specified.

  • Returns the count of elements in a SortedSet whose score is greater than a minimum score value.

    By default, the value provided will be treated as inclusive, meaning any element that has a score matching the value will be counted.

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

    Declaration

    Swift

    public func zcount(of key: RedisKey, withMinimumScoreOf minScore: RedisZScoreBound) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet that will be counted.

    minScore

    The minimum score bound an element in the SortedSet should have in order to be counted.

    Return Value

    The count of elements in the SortedSet above the minScore threshold.

  • Returns the count of elements in a SortedSet whose score is less than a maximum score value.

    By default, the value provided will be treated as inclusive, meaning any element that has a score matching the value will be counted.

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

    Declaration

    Swift

    public func zcount(of key: RedisKey, withMaximumScoreOf maxScore: RedisZScoreBound) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet that will be counted.

    maxScore

    The maximum score bound an element in the SortedSet should have in order to be counted.

    exclusive

    Should the maxScore provided be exclusive? If true, scores matching the maxScore will not be counted.

    Return Value

    The count of elements in the SortedSet below the maxScore threshold.

  • Returns the count of elements in a SortedSet whose lexiographical values are between the range specified.

    For example:

    // "mySortedSet" contains the values [1, 2, 3, 10] each with a score of 1.
    client.zlexcount(of: "mySortedSet", withValuesBetween: (.inclusive(1), .inclusive(3)))
    // the response will resolve to 4, as both 10 and 1 have the value "1"
    

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

    Warning

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

    Declaration

    Swift

    @inlinable
    public func zlexcount<Value: CustomStringConvertible>(
        of key: RedisKey,
        withValuesBetween range: (min: RedisZLexBound<Value>, max: RedisZLexBound<Value>)
    ) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet that will be counted.

    range

    The min and max value bounds that an element should have in order to be counted.

    Return Value

    The count of elements in the SortedSet with values matching the range specified.

  • Returns the count of elements in a SortedSet whose lexiographical value is greater than a minimum value.

    For example with a SortedSet that contains the values [1, 2, 3, 10] and each a score of 1:

    client.zlexcount(of: "mySortedSet", withMinimumValueOf: .inclusive(2))
    // the response will resolve to 2, as "10" lexiographically comes before element "2"
    
    client.zlexcount(of: "mySortedSet", withMinimumValueOf: .inclusive(10))
    // the response will resolve to 3, as the set is ordered as ["1", "10", "2", "3"]
    

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

    Warning

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

    Declaration

    Swift

    @inlinable
    public func zlexcount<Value: CustomStringConvertible>(
        of key: RedisKey,
        withMinimumValueOf minValue: RedisZLexBound<Value>
    ) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet that will be counted.

    minValue

    The minimum lexiographical value an element in the SortedSet should have in order to be counted.

    Return Value

    The count of elements in the SortedSet above the minValue threshold.

  • Returns the count of elements in a SortedSet whose lexiographical value is less than a maximum value.

    For example with a SortedSet that contains the values [1, 2, 3, 10] and each a score of 1:

    client.zlexcount(of: "mySortedSet", withMaximumValueOf: .exclusive(10))
    // the response will resolve to 1, as "1" and "10" are sorted into the first 2 elements
    
    client.zlexcount(of: "mySortedSet", withMaximumValueOf: .inclusive(3))
    // the response will resolve to 4, as the set is ordered as ["1", "10", "2", "3"]
    

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

    Warning

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

    Declaration

    Swift

    @inlinable
    public func zlexcount<Value: CustomStringConvertible>(
        of key: RedisKey,
        withMaximumValueOf maxValue: RedisZLexBound<Value>
    ) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet that will be counted.

    maxValue

    The maximum lexiographical value an element in the SortedSet should have in order to be counted.

    Return Value

    The count of elements in the SortedSet below the maxValue threshold.

  • zpopmin(from:max:) Extension method

    Removes elements from a sorted set with the lowest scores.

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

    Declaration

    Swift

    public func zpopmin(from key: RedisKey, 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

    public func zpopmin(from key: RedisKey) -> 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

    public func zpopmax(from key: RedisKey, 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

    public func zpopmax(from key: RedisKey) -> 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

    public func bzpopmin(
        from key: RedisKey,
        timeout: TimeAmount = .seconds(0)
    ) -> EventLoopFuture<(Double, RESPValue)?>

    Parameters

    key

    The key identifying the sorted set in Redis.

    timeout

    The max time to wait for a value to use. 0seconds means to wait 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

    public func bzpopmin(
        from keys: [RedisKey],
        timeout: TimeAmount = .seconds(0)
    ) -> EventLoopFuture<(String, Double, RESPValue)?>

    Parameters

    keys

    A list of sorted set keys in Redis.

    timeout

    The max time to wait for a value to use. 0seconds means to wait 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

    public func bzpopmax(
        from key: RedisKey,
        timeout: TimeAmount = .seconds(0)
    ) -> EventLoopFuture<(Double, RESPValue)?>

    Parameters

    key

    The key identifying the sorted set in Redis.

    timeout

    The max time to wait for a value to use. 0seconds means to wait 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

    public func bzpopmax(
        from keys: [RedisKey],
        timeout: TimeAmount = .seconds(0)
    ) -> EventLoopFuture<(String, Double, RESPValue)?>

    Parameters

    keys

    A list of sorted set keys in Redis.

    timeout

    The max time to wait for a value to use. 0seconds means to wait 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: RedisKey
    ) -> 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

    public func zunionstore(
        as destination: RedisKey,
        sources: [RedisKey],
        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

    public func zinterstore(
        as destination: RedisKey,
        sources: [RedisKey],
        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 all elements from a SortedSet within the specified inclusive bounds of 0-based indices.

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

    Important

    This treats the SortedSet as ordered from low to high.

    For the inverse, see zrevrange(from:firstIndex:lastIndex:includeScoresInResponse:).

    Declaration

    Swift

    public func zrange(
        from key: RedisKey,
        firstIndex: Int,
        lastIndex: Int,
        includeScoresInResponse includeScores: Bool = false
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet

    firstIndex

    The index of the first element to include in the range of elements returned.

    lastIndex

    The index of the last element to include in the range of elements returned.

    Return Value

    An array of elements found within the range specified.

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

    To get the elements at index 4 through 7:

    client.zrange(from: "mySortedSet", indices: 4...7)
    

    To get the last 4 elements:

    client.zrange(from: "mySortedSet", indices: (-4)...(-1))
    

    To get the first and last 4 elements:

    client.zrange(from: "mySortedSet", indices: (-4)...3)
    

    To get the first element, and the last 4:

    client.zrange(from: "mySortedSet", indices: (-4)...0))
    

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

    Warning

    A ClosedRange cannot be created where upperBound is less than lowerBound; so while Redis may support 0...-1, ClosedRange will trigger a precondition failure.

    If you need such a range, use zrange(from:firstIndex:lastIndex:) instead.

    Important

    This treats the SortedSet as ordered from low to high.

    For the inverse, see zrevrange(from:indices:includeScoresInResponse:).

    Declaration

    Swift

    public func zrange(
        from key: RedisKey,
        indices range: ClosedRange<Int>,
        includeScoresInResponse includeScores: Bool = false
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet to return elements from.

    range

    The range of inclusive indices of elements to get.

    Return Value

    An array of elements found within the range specified.

  • Gets all the elements from a SortedSet starting with the first index bound up to, but not including, the element at the last index bound.

    To get the elements at index 4 through 7:

    client.zrange(from: "mySortedSet", indices: 4..<8)
    

    To get the last 4 elements:

    client.zrange(from: "mySortedSet", indices: (-4)..<0)
    

    To get the first and last 4 elements:

    client.zrange(from: "mySortedSet", indices: (-4)..<4)
    

    To get the first element, and the last 4:

    client.zrange(from: "mySortedSet", indices: (-4)..<1)
    

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

    Warning

    A Range cannot be created where upperBound is less than lowerBound; so while Redis may support 0..<(-1), Range will trigger a precondition failure.

    If you need such a range, use zrange(from:firstIndex:lastIndex:) instead.

    Important

    This treats the SortedSet as ordered from low to high.

    For the inverse, see zrevrange(from:indices:includeScoresInResponse:).

    Declaration

    Swift

    public func zrange(
        from key: RedisKey,
        indices range: Range<Int>,
        includeScoresInResponse includeScores: Bool = false
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet to return elements from.

    range

    The range of indices (inclusive lower, exclusive upper) elements to get.

    Return Value

    An array of elements found within the range specified.

  • Gets all elements from the index specified to the end of a SortedSet.

    To get all except the first 2 elements of a SortedSet:

    client.zrange(from: "mySortedSet", fromIndex: 2)
    

    To get the last 4 elements of a SortedSet:

    client.zrange(from: "mySortedSet", fromIndex: -4)
    

    See zrange(from:indices:), zrange(from:firstIndex:lastIndex:), and https://redis.io/commands/zrange

    Important

    This treats the SortedSet as ordered from low to high.

    For the inverse, see zrevrange(from:fromIndex:includeScoresInResponse:).

    Declaration

    Swift

    public func zrange(
        from key: RedisKey,
        fromIndex index: Int,
        includeScoresInResponse includeScores: Bool = false
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet to return elements from.

    index

    The index of the first element that will be in the returned values.

    Return Value

    An array of elements from the SortedSet between the index and the end.

  • Gets all elements from the start of a SortedSet up to, and including, the element at the index specified.

    To get the first 3 elements of a SortedSet:

    client.zrange(from: "mySortedSet", throughIndex: 2)
    

    To get all except the last 3 elements of a SortedSet:

    client.zrange(from: "mySortedSet", throughIndex: -4)
    

    See zrange(from:indices:), zrange(from:firstIndex:lastIndex:), and https://redis.io/commands/zrange

    Important

    This treats the SortedSet as ordered from low to high.

    For the inverse, see zrevrange(from:throughIndex:includeScoresInResponse:).

    Declaration

    Swift

    public func zrange(
        from key: RedisKey,
        throughIndex index: Int,
        includeScoresInResponse includeScores: Bool = false
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet to return elements from.

    index

    The index of the last element that will be in the returned values.

    Return Value

    An array of elements from the start of a SortedSet to the index.

  • Gets all elements from the start of a SortedSet up to, but not including, the element at the index specified.

    To get the first 3 elements of a List:

    client.zrange(from: "myList", upToIndex: 3)
    

    To get all except the last 3 elements of a List:

    client.zrange(from: "myList", upToIndex: -3)
    

    See zrange(from:indices:), zrange(from:upToIndex:lastIndex:), and https://redis.io/commands/zrange

    Important

    This treats the SortedSet as ordered from low to high.

    For the inverse, see zrevrange(from:upToIndex:includeScoresInResponse:).

    Declaration

    Swift

    public func zrange(
        from key: RedisKey,
        upToIndex index: Int,
        includeScoresInResponse includeScores: Bool = false
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet to return elements from.

    index

    The index of the last element to not include in the returned values.

    Return Value

    An array of elements from the start of the SortedSet and up to the index.

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

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

    Important

    This treats the SortedSet as ordered from high to low.

    For the inverse, see zrange(from:firstIndex:lastIndex:includeScoresInResponse:).

    Declaration

    Swift

    public func zrevrange(
        from key: RedisKey,
        firstIndex: Int,
        lastIndex: Int,
        includeScoresInResponse includeScores: Bool = false
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet

    firstIndex

    The index of the first element to include in the range of elements returned.

    lastIndex

    The index of the last element to include in the range of elements returned.

    Return Value

    An array of elements found within the range specified.

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

    To get the elements at index 4 through 7:

    client.zrevrange(from: "mySortedSet", indices: 4...7)
    

    To get the last 4 elements:

    client.zrevrange(from: "mySortedSet", indices: (-4)...(-1))
    

    To get the first and last 4 elements:

    client.zrevrange(from: "mySortedSet", indices: (-4)...3)
    

    To get the first element, and the last 4:

    client.zrevrange(from: "mySortedSet", indices: (-4)...0))
    

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

    Warning

    A ClosedRange cannot be created where upperBound is less than lowerBound; so while Redis may support 0...-1, ClosedRange will trigger a precondition failure.

    If you need such a range, use zrevrange(from:firstIndex:lastIndex:) instead.

    Important

    This treats the SortedSet as ordered from high to low.

    For the inverse, see zrange(from:indices:includeScoresInResponse:).

    Declaration

    Swift

    public func zrevrange(
        from key: RedisKey,
        indices range: ClosedRange<Int>,
        includeScoresInResponse includeScores: Bool = false
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet to return elements from.

    range

    The range of inclusive indices of elements to get.

    Return Value

    An array of elements found within the range specified.

  • Gets all the elements from a SortedSet starting with the first index bound up to, but not including, the element at the last index bound.

    To get the elements at index 4 through 7:

    client.zrevrange(from: "mySortedSet", indices: 4..<8)
    

    To get the last 4 elements:

    client.zrevrange(from: "mySortedSet", indices: (-4)..<0)
    

    To get the first and last 4 elements:

    client.zrevrange(from: "mySortedSet", indices: (-4)..<4)
    

    To get the first element, and the last 4:

    client.zrevrange(from: "mySortedSet", indices: (-4)..<1)
    

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

    Warning

    A Range cannot be created where upperBound is less than lowerBound; so while Redis may support 0..<(-1), Range will trigger a precondition failure.

    If you need such a range, use zrevrange(from:firstIndex:lastIndex:) instead.

    Important

    This treats the SortedSet as ordered from high to low.

    For the inverse, see zrange(from:indices:includeScoresInResponse:).

    Declaration

    Swift

    public func zrevrange(
        from key: RedisKey,
        indices range: Range<Int>,
        includeScoresInResponse includeScores: Bool = false
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet to return elements from.

    range

    The range of indices (inclusive lower, exclusive upper) elements to get.

    Return Value

    An array of elements found within the range specified.

  • Gets all elements from the index specified to the end of a SortedSet.

    To get all except the first 2 elements of a SortedSet:

    client.zrevrange(from: "mySortedSet", fromIndex: 2)
    

    To get the last 4 elements of a SortedSet:

    client.zrevrange(from: "mySortedSet", fromIndex: -4)
    

    See zrevrange(from:indices:), zrevrange(from:firstIndex:lastIndex:), and https://redis.io/commands/zrevrange

    Important

    This treats the SortedSet as ordered from high to low.

    For the inverse, see zrange(from:fromIndex:includeScoresInResponse:).

    Declaration

    Swift

    public func zrevrange(
        from key: RedisKey,
        fromIndex index: Int,
        includeScoresInResponse includeScores: Bool = false
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet to return elements from.

    index

    The index of the first element that will be in the returned values.

    Return Value

    An array of elements from the SortedSet between the index and the end.

  • Gets all elements from the start of a SortedSet up to, and including, the element at the index specified.

    To get the first 3 elements of a SortedSet:

    client.zrevrange(from: "mySortedSet", throughIndex: 2)
    

    To get all except the last 3 elements of a SortedSet:

    client.zrevrange(from: "mySortedSet", throughIndex: -4)
    

    See zrevrange(from:indices:), zrevrange(from:firstIndex:lastIndex:), and https://redis.io/commands/zrevrange

    Important

    This treats the SortedSet as ordered from high to low.

    For the inverse, see zrange(from:throughIndex:includeScoresInResponse:).

    Declaration

    Swift

    public func zrevrange(
        from key: RedisKey,
        throughIndex index: Int,
        includeScoresInResponse includeScores: Bool = false
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet to return elements from.

    index

    The index of the last element that will be in the returned values.

    Return Value

    An array of elements from the start of a SortedSet to the index.

  • Gets all elements from the start of a SortedSet up to, but not including, the element at the index specified.

    To get the first 3 elements of a List:

    client.zrevrange(from: "myList", upToIndex: 3)
    

    To get all except the last 3 elements of a List:

    client.zrevrange(from: "myList", upToIndex: -3)
    

    See zrevrange(from:indices:), zrevrange(from:upToIndex:lastIndex:), and https://redis.io/commands/zrevrange

    Important

    This treats the SortedSet as ordered from high to low.

    For the inverse, see zrange(from:upToIndex:includeScoresInResponse:).

    Declaration

    Swift

    public func zrevrange(
        from key: RedisKey,
        upToIndex index: Int,
        includeScoresInResponse includeScores: Bool = false
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet to return elements from.

    index

    The index of the last element to not include in the returned values.

    Return Value

    An array of elements from the start of the SortedSet and up to the index.

  • Gets all elements from a SortedSet whose lexiographical values are between the range specified.

    For example:

    // "mySortedSet" contains the values [1, 2, 3, 10] each with a score of 1
    client.zrangebylex(of: "mySortedSet", withValuesBetween: (.inclusive(1), .exclusive(3)))
    // the response resolves to [1, 10, 2]
    

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

    Warning

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

    Important

    This treats the SortedSet as ordered from low to high.

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

    Declaration

    Swift

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

    Parameters

    key

    The key of the SortedSet that will be counted.

    range

    The min and max value bounds for filtering elements by.

    limitBy

    The optional offset and count of elements to query.

    Return Value

    An array of elements from the SortedSet that were within the range provided.

  • Gets all elements from a SortedSet whose lexiographical value is greater than a minimum value.

    // "mySortedSet" contains the values [1, 2, 3, 10] each with a score of 1
    client.zrangebylex(of: "mySortedSet", withMinimumValueOf: .inclusive(1))
    // the response resolves to [1, 10, 2, 3]
    

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

    Warning

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

    Important

    This treats the SortedSet as ordered from low to high.

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

    Declaration

    Swift

    @inlinable
    public func zrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withMinimumValueOf minValue: RedisZLexBound<Value>,
        limitBy limit: (offset: Int, count: Int)? = nil
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet.

    minValue

    The minimum lexiographical value an element in the SortedSet should have to be included in the result set.

    limit

    The optional offset and count of elements to query

    Return Value

    An array of elements from the SortedSet above the minValue threshold.

  • Gets all elements from a SortedSet whose lexiographical value is less than a maximum value.

    // "mySortedSet" contains the values [1, 2, 3, 10] each with a score of 1
    client.zlexcount(of: "mySortedSet", withMaximumValueOf: .exclusive(2))
    // the response resolves to [1, 10]
    

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

    Warning

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

    Important

    This treats the SortedSet as ordered from low to high.

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

    Declaration

    Swift

    @inlinable
    public func zrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withMaximumValueOf maxValue: RedisZLexBound<Value>,
        limitBy limit: (offset: Int, count: Int)? = nil
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet.

    minValue

    The maximum lexiographical value an element in the SortedSet should have to be included in the result set.

    limit

    The optional offset and count of elements to query

    Return Value

    An array of elements from the SortedSet below the maxValue threshold.

  • Gets all elements from a SortedSet whose lexiographical values are between the range specified.

    For example:

    // "mySortedSet" contains the values [1, 2, 3, 10] each with a score of 1
    client.zrevrangebylex(of: "mySortedSet", withValuesBetween: (.inclusive(1), .exclusive(3)))
    // the response resolves to [2, 10 1]
    

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

    Warning

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

    Important

    This treats the SortedSet as ordered from high to low.

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

    Declaration

    Swift

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

    Parameters

    key

    The key of the SortedSet that will be counted.

    range

    The min and max value bounds for filtering elements by.

    limitBy

    The optional offset and count of elements to query.

    Return Value

    An array of elements from the SortedSet that were within the range provided.

  • Gets all elements from a SortedSet whose lexiographical value is greater than a minimum value.

    // "mySortedSet" contains the values [1, 2, 3, 10] each with a score of 1
    client.zrevrangebylex(of: "mySortedSet", withMinimumValueOf: .inclusive(1))
    // the response resolves to [3, 2, 10, 1]
    

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

    Warning

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

    Important

    This treats the SortedSet as ordered from high to low.

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

    Declaration

    Swift

    @inlinable
    public func zrevrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withMinimumValueOf minValue: RedisZLexBound<Value>,
        limitBy limit: (offset: Int, count: Int)? = nil
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet.

    minValue

    The minimum lexiographical value an element in the SortedSet should have to be included in the result set.

    limit

    The optional offset and count of elements to query

    Return Value

    An array of elements from the SortedSet above the minValue threshold.

  • Gets all elements from a SortedSet whose lexiographical value is less than a maximum value.

    // "mySortedSet" contains the values [1, 2, 3, 10] each with a score of 1
    client.zrevrangebylex(of: "mySortedSet", withMaximumValueOf: .exclusive(2))
    // the response resolves to [10, 1]
    

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

    Warning

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

    Important

    This treats the SortedSet as ordered from high to low.

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

    Declaration

    Swift

    @inlinable
    public func zrevrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withMaximumValueOf maxValue: RedisZLexBound<Value>,
        limitBy limit: (offset: Int, count: Int)? = nil
    ) -> EventLoopFuture<[RESPValue]>

    Parameters

    key

    The key of the SortedSet.

    minValue

    The maximum lexiographical value an element in the SortedSet should have to be included in the result set.

    limit

    The optional offset and count of elements to query

    Return Value

    An array of elements from the SortedSet below the maxValue threshold.

  • 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: RedisKey) -> 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: RedisKey) -> 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.

  • Removes elements from a SortedSet whose lexiographical values are between the range specified.

    For example:

    // "mySortedSet" contains the values [1, 2, 3, 10] each with a score of 1.
    client.zremrangebylex(from: "mySortedSet", withValuesBetween: (.inclusive(10), .exclusive(3))
    // elements 10 and 2 were removed
    

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

    Warning

    This assumes all elements in the SortedSet have the same score. If not, the elements removed are unspecified.

    Declaration

    Swift

    @inlinable
    public func zremrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withValuesBetween range: (min: RedisZLexBound<Value>, max: RedisZLexBound<Value>)
    ) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    range

    The min and max value bounds that an element should have to be removed.

    Return Value

    The count of elements that were removed from the SortedSet.

  • Removes elements from a SortedSet whose lexiographical values are greater than a minimum value.

    For example:

    // "mySortedSet" contains the values [1, 2, 3, 10] each with a score of 1.
    client.zremrangebylex(from: "mySortedSet", withMinimumValueOf: .inclusive(10))
    // elements 10, 2, and 3 are removed
    

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

    Warning

    This assumes all elements in the SortedSet have the same score. If not, the elements removed are unspecified.

    Declaration

    Swift

    @inlinable
    public func zremrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withMinimumValueOf minValue: RedisZLexBound<Value>
    ) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    minValue

    The minimum lexiographical value an element in the SortedSet should have to be removed.

    Return Value

    The count of elements that were removed from the SortedSet.

  • Removes elements from a SortedSet whose lexiographical values are less than a maximum value.

    For example:

    // "mySortedSet" contains the values [1, 2, 3, 10] each with a score of 1.
    client.zremrangebylex(from: "mySortedSet", withMaximumValueOf: .exclusive(2))
    // elements 1 and 10 are removed
    

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

    Warning

    This assumes all elements in the SortedSet have the same score. If not, the elements removed are unspecified.

    Declaration

    Swift

    @inlinable
    public func zremrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withMaximumValueOf maxValue: RedisZLexBound<Value>
    ) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    maxValue

    The maximum lexiographical value and element in the SortedSet should have to be removed.

    Return Value

    The count of elements that were removed from the SortedSet.

  • Removes all elements from a SortedSet within the specified inclusive bounds of 0-based indices.

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

    Declaration

    Swift

    public func zremrangebyrank(from key: RedisKey, firstIndex: Int, lastIndex: Int) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    firstIndex

    The index of the first element to remove.

    lastIndex

    The index of the last element to remove.

    Return Value

    The count of elements that were removed from the SortedSet.

  • Removes all elements from a SortedSet within the specified inclusive bounds of 0-based indices.

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

    Warning

    A ClosedRange cannot be created where upperBound is less than lowerBound; so while Redis may support 0...-1, ClosedRange will trigger a precondition failure.

    If you need such a range, use zremrangebyrank(from:firstIndex:lastIndex:) instead.

    Declaration

    Swift

    public func zremrangebyrank(from key: RedisKey, indices range: ClosedRange<Int>) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    range

    The range of inclusive indices of elements to remove.

    Return Value

    The count of elements that were removed from the SortedSet.

  • Removes all elements from a SortedSet starting with the first index bound up to, but not including, the element at the last index bound.

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

    Warning

    A Range cannot be created where upperBound is less than lowerBound; so while Redis may support 0...-1, Range will trigger a precondition failure.

    If you need such a range, use zremrangebyrank(from:firstIndex:lastIndex:) instead.

    Declaration

    Swift

    public func zremrangebyrank(from key: RedisKey, indices range: Range<Int>) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    range

    The range of indices (inclusive lower, exclusive upper) elements to remove.

    Return Value

    The count of elements that were removed from the SortedSet.

  • Removes all elements from the index specified to the end of a SortedSet.

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

    Declaration

    Swift

    public func zremrangebyrank(from key: RedisKey, fromIndex index: Int) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    index

    The index of the first element that will be removed.

    Return Value

    The count of elements that were removed from the SortedSet.

  • Removes all elements from the start of a SortedSet up to, and including, the element at the index specified.

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

    Declaration

    Swift

    public func zremrangebyrank(from key: RedisKey, throughIndex index: Int) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    index

    The index of the last element that will be removed.

    Return Value

    The count of elements that were removed from the SortedSet.

  • Removes all elements from the start of a SortedSet up to, but not including, the element at the index specified.

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

    Warning

    Providing an index of 0 will remove all elements from the SortedSet.

    Declaration

    Swift

    public func zremrangebyrank(from key: RedisKey, upToIndex index: Int) -> EventLoopFuture<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    index

    The index of the last element to not remove.

    Return Value

    The count of elements that were removed from the SortedSet.

  • get(_:) Extension method

    Get the value of a key.

    https://redis.io/commands/get

    Declaration

    Swift

    public func get(_ key: RedisKey) -> EventLoopFuture<RESPValue>

    Parameters

    key

    The key to fetch the value from.

    Return Value

    The value stored at the key provided. If the key does not exist, the value will be .null.

  • 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: RedisKey,
        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 type 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

    public func mget(_ keys: [RedisKey]) -> 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(_:as:) 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<Value>(_ keys: [RedisKey], as type: Value.Type) -> EventLoopFuture<[Value?]> where Value : RESPValueConvertible

    Parameters

    keys

    The list of keys to fetch the values from.

    type

    The type to convert the values to.

    Return Value

    The values stored at the keys provided, matching the same order. Values that fail the RESPValue conversion will be nil.

  • 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

    public func mget(_ keys: RedisKey...) -> 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(_:as:) 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<Value>(_ keys: RedisKey..., as type: Value.Type) -> EventLoopFuture<[Value?]> where Value : RESPValueConvertible

    Parameters

    keys

    The list of keys to fetch the values from.

    type

    The type to convert the values to.

    Return Value

    The values stored at the keys provided, matching the same order. Values that fail the RESPValue conversion will be nil.

  • 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: RedisKey) -> 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: RedisKey, 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.

  • Sets the key to the provided value with options to control how it is set.

    https://redis.io/commands/set

    Important

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

    ie. If the key is a reference to a Sorted Set, its value will be overwritten to be a “string” data type.

    Declaration

    Swift

    public func set<Value: RESPValueConvertible>(
        _ key: RedisKey,
        to value: Value,
        onCondition condition: RedisSetCommandCondition,
        expiration: RedisSetCommandExpiration? = nil
    ) -> EventLoopFuture<RedisSetCommandResult>

    Parameters

    key

    The key to use to uniquely identify this value.

    value

    The value to set the key to.

    condition

    The condition under which the key should be set.

    expiration

    The expiration to use when setting the key. No expiration is set if nil.

    Return Value

    A NIO.EventLoopFuture indicating the result of the operation; .ok if the operation was successful and .conditionNotMet if the specified condition was not met.

    If the condition .none was used, then the result value will always be .ok.

  • setnx(_:to:) Extension method

    Sets the key to the provided value if the key does not exist.

    https://redis.io/commands/setnx

    Important

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

    ie. If the key is a reference to a Sorted Set, its value will be overwritten to be a “string” data type.

    Declaration

    Swift

    @inlinable
    public func setnx<Value>(_ key: RedisKey, to value: Value) -> EventLoopFuture<Bool> where Value : RESPValueConvertible

    Parameters

    key

    The key to use to uniquely identify this value.

    value

    The value to set the key to.

    Return Value

    true if the operation successfully completed.

  • Sets a key to the provided value and an expiration timeout in seconds.

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

    Important

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

    ie. If the key is a reference to a Sorted Set, its value will be overwritten to be a “string” data type.

    Important

    The actual expiration used will be the specified value or 1, whichever is larger.

    Declaration

    Swift

    @inlinable
    public func setex<Value: RESPValueConvertible>(
        _ key: RedisKey,
        to value: Value,
        expirationInSeconds expiration: Int
    ) -> EventLoopFuture<Void>

    Parameters

    key

    The key to use to uniquely identify this value.

    value

    The value to set the key to.

    expiration

    The number of seconds after which to expire the key.

    Return Value

    A NIO.EventLoopFuture that resolves if the operation was successful.

  • Sets a key to the provided value and an expiration timeout in milliseconds.

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

    Important

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

    ie. If the key is a reference to a Sorted Set, its value will be overwritten to be a “string” data type.

    Important

    The actual expiration used will be the specified value or 1, whichever is larger.

    Declaration

    Swift

    @inlinable
    public func psetex<Value: RESPValueConvertible>(
        _ key: RedisKey,
        to value: Value,
        expirationInMilliseconds expiration: Int
    ) -> EventLoopFuture<Void>

    Parameters

    key

    The key to use to uniquely identify this value.

    value

    The value to set the key to.

    expiration

    The number of milliseconds after which to expire the key.

    Return Value

    A NIO.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: [RedisKey : 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: [RedisKey : 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.