RedisCommand

public struct RedisCommand<ResultType>

An abstract representation of a Redis command that can be sent to a Redis instance.

An instance will retain the keyword of the command in plaintext as a String for identity purposes, while all the arguments will be stored as RESPValue representations.

ResultType

Each RedisCommand has a generic type referred to as ResultType that is the native Swift representation of the response Redis will send for the command.

When creating a RedisCommand, a closure will be provided for transforming an arbitrary RESPValue instance into the ResultType.

  • Undocumented

    Declaration

    Swift

    public let keyword: String
  • Undocumented

    Declaration

    Swift

    public let arguments: [RESPValue]
  • Creates a command with the given details that represents a Redis command in Swift.

    Warning

    The transform closure is escaping, and will retain references to any scope captures.

    Declaration

    Swift

    public init(
        keyword: String,
        arguments: [RESPValue],
        mapValueToResult transform: @escaping (RESPValue) throws -> ResultType
    )

    Parameters

    keyword

    The command keyword as defined by Redis.

    arguments

    The command arguments to be sent to Redis.

    transform

    The closure to invoke to transform the value from its raw RESPValue instance to the desired final ResultType.

  • Serializes the entire command into a single value for sending to Redis.

    Declaration

    Swift

    public func serialized() -> RESPValue

    Return Value

    A RESPValue.array value of the keyword and its arguments.

  • Declaration

    Swift

    public static func echo(_ message: String) -> RedisCommand<String>

    Parameters

    message

    The message to echo.

  • Declaration

    Swift

    public static func ping(with message: String? = nil) -> RedisCommand<String>

    Parameters

    message

    The optional message that the server should respond with instead of the default.

  • Declaration

    Swift

    public static func auth(with password: String) -> RedisCommand<Void>

    Parameters

    password

    The password to authenticate with.

  • Declaration

    Swift

    public static func select(database index: Int) -> RedisCommand<Void>

    Parameters

    index

    The 0-based index of the database that the connection that sends this command will execute later commands against.

  • DEL

    Declaration

    Swift

    public static func del(_ keys: [RedisKey]) -> RedisCommand<Int>

    Parameters

    keys

    The list of keys to delete from the database.

  • Declaration

    Swift

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

    Parameters

    keys

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

  • Declaration

    Swift

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

    Parameters

    keys

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

  • EXPIRE

    Note

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

    Declaration

    Swift

    public static func expire(_ key: RedisKey, after timeout: TimeAmount) -> RedisCommand<Bool>

    Parameters

    key

    The key to set the expiration on.

    timeout

    The time from now the key will expire at.

  • TTL

    Declaration

    Swift

    public static func ttl(_ key: RedisKey) -> RedisCommand<RedisKey.Lifetime>

    Parameters

    key

    The key to check the time-to-live on.

  • Declaration

    Swift

    public static func pttl(_ key: RedisKey) -> RedisCommand<RedisKey.Lifetime>

    Parameters

    key

    The key to check the time-to-live on.

  • Declaration

    Swift

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

    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.

  • BLPOP

    Warning

    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.

    Declaration

    Swift

    public static func blpop(from key: RedisKey, timeout: TimeAmount = .seconds(0)) -> RedisCommand<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.

  • BLPOP

    Warning

    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.

    Declaration

    Swift

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

    Parameters

    keys

    The list of keys to pop from.

    timeout

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

  • BLPOP

    Warning

    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.

    Declaration

    Swift

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

    Parameters

    keys

    The list of keys to pop from.

    timeout

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

  • BRPOP

    Warning

    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.

    Declaration

    Swift

    public static func brpop(from key: RedisKey, timeout: TimeAmount = .seconds(0)) -> RedisCommand<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.

  • BRPOP

    Warning

    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.

    Declaration

    Swift

    public static func brpop(from keys: [RedisKey], timeout: TimeAmount = .seconds(0)) -> RedisCommand<(RedisKey, 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.

  • BRPOP

    Warning

    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.

    Declaration

    Swift

    public static func brpop(
        from keys: RedisKey...,
        timeout: TimeAmount = .seconds(0)
    ) -> RedisCommand<(RedisKey, 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.

  • BRPOPLPUSH

    Warning

    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.

    Declaration

    Swift

    public static func brpoplpush(
        from source: RedisKey,
        to dest: RedisKey,
        timeout: TimeAmount = .seconds(0)
    ) -> RedisCommand<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.

  • Declaration

    Swift

    public static func lindex(_ index: Int, from key: RedisKey) -> RedisCommand<RESPValue?>

    Parameters

    index

    The 0-based index of the element to get.

    key

    The key of the list.

  • Declaration

    Swift

    @inlinable
    public static func linsert<Value: RESPValueConvertible>(
        _ element: Value,
        into key: RedisKey,
        before pivot: Value
    ) -> RedisCommand<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.

  • Declaration

    Swift

    @inlinable
    public static func linsert<Value: RESPValueConvertible>(
        _ element: Value,
        into key: RedisKey,
        after pivot: Value
    ) -> RedisCommand<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.

  • Declaration

    Swift

    public static func llen(of key: RedisKey) -> RedisCommand<Int>

    Parameters

    key

    The key of the list.

  • Declaration

    Swift

    public static func lpop(from key: RedisKey) -> RedisCommand<RESPValue?>

    Parameters

    key

    The key of the list to pop from.

  • LPUSH

    Note

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

    Declaration

    Swift

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

    Parameters

    elements

    The values to push into the list.

    key

    The key of the list.

  • LPUSH

    Note

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

    Declaration

    Swift

    @inlinable
    public static func lpush<Value: RESPValueConvertible>(
        _ elements: Value...,
        into key: RedisKey
    ) -> RedisCommand<Int>

    Parameters

    elements

    The values to push into the list.

    key

    The key of the list.

  • LPUSHX

    Note

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

    Declaration

    Swift

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

    Parameters

    element

    The value to try and push into the list.

    key

    The key of the list.

  • Declaration

    Swift

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

    Parameters

    key

    The key of the List.

    firstIndex

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

    lastIndex

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

  • LRANGE

    Example usage:

    // elements at indices 4-7
    client.send(.lrange(from: "myList", indices: 4...7))
    
    // last 4 elements
    client.send(.lrange(from: "myList", indices: (-4)...(-1)))
    
    // first and last 4 elements
    client.send(.lrange(from: "myList", indices: (-4)...3))
    
    // first element, and the last 4
    client.send(.lrange(from: "myList", indices: (-4)...0))
    

    Precondition

    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 static func lrange(from key: RedisKey, indices range: ClosedRange<Int>) -> RedisCommand<[RESPValue]>

    Parameters

    key

    The key of the List to return elements from.

    range

    The range of inclusive indices of elements to get.

  • LRANGE

    Example usage:

    // elements at indicies 4-7
    client.send(.lrange(from: "myList", indices: 4..<8))
    
    // last 4 elements
    client.send(.lrange(from: "myList", indices: (-4)..<0))
    
    // first and last 4 elements
    client.send(.lrange(from: "myList", indices: (-4)..<4))
    
    // first element and the last 4
    client.send(.lrange(from: "myList", indices: (-4)..<1))
    

    Precondition

    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 static func lrange(from key: RedisKey, indices range: Range<Int>) -> RedisCommand<[RESPValue]>

    Parameters

    key

    The key of the List to return elements from.

    range

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

  • LRANGE

    Example usage:

    // all except first 2 elements
    client.send(.lrange(from: "myList", fromIndex: 2))
    
    // last 4 elements
    client.send(.lrange(from: "myList", fromIndex: -4))
    

    Declaration

    Swift

    public static func lrange(from key: RedisKey, fromIndex index: Int) -> RedisCommand<[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.

  • LRANGE

    Example usage:

    // first 3 elements
    client.send(.lrange(from: "myList", throughIndex: 2))
    
    // all except last 3 elements
    client.send(.lrange(from: "myList", throughIndex: -4))
    

    Declaration

    Swift

    public static func lrange(from key: RedisKey, throughIndex index: Int) -> RedisCommand<[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.

  • LRANGE

    Example usage:

    // first 3 elements
    client.send(.lrange(from: "myList", upToIndex: 3))
    
    // all except last 3 elements
    client.send(.lrange(from: "myList", upToIndex: -3))
    

    Declaration

    Swift

    public static func lrange(from key: RedisKey, upToIndex index: Int) -> RedisCommand<[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.

  • Declaration

    Swift

    @inlinable
    public static func lrem<Value: RESPValueConvertible>(
        _ value: Value,
        from key: RedisKey,
        count: Int = 0
    ) -> RedisCommand<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.

  • Declaration

    Swift

    @inlinable
    public static func lset<Value: RESPValueConvertible>(
        index: Int,
        to value: Value,
        in key: RedisKey
    ) -> RedisCommand<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.

  • Declaration

    Swift

    @inlinable
    public static func ltrim(_ key: RedisKey, before start: Int, after stop: Int) -> RedisCommand<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.

  • LTRIM

    Example usage:

    // keep elements at indices 4-7
    client.send(.ltrim("myList", keepingIndices: 3...6))
    
    // keep last 4-7 elements
    client.send(.ltrim("myList", keepingIndices: (-7)...(-4)))
    
    // keep first element and last 4
    client.send(.ltrim("myList", keepingIndices: (-4)...3))
    

    Precondition

    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 static func ltrim(_ key: RedisKey, keepingIndices range: ClosedRange<Int>) -> RedisCommand<Void>

    Parameters

    key

    The key of the List to trim.

    range

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

  • LTRIM

    Example usage:

    // keep all but the first 3 elements
    client.send(.ltrim("myList", keepingIndices: 3...))
    
    // keep last 4 elements
    client.send(.ltrim("myList", keepingIndices: (-4)...))
    

    Declaration

    Swift

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

    Parameters

    key

    The key of the List to trim.

    range

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

  • LTRIM

    Example usage:

    // keep first 3 elements
    client.send(.ltrim("myList", keepingIndices: ..<3))
    
    // keep all but the last 4 elements
    client.send(.ltrim("myList", keepingIndices: ..<(-4)))
    

    Declaration

    Swift

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

    Parameters

    key

    The key of the List to trim.

    range

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

  • LTRIM

    Example usage:

    // keep first 4 elements
    client.send(.ltrim("myList", keepingIndices: ...3))
    
    // keep all but the last 3 elements
    client.send(.ltrim("myList", keepingIndices: ...(-4)))
    

    Declaration

    Swift

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

    Parameters

    key

    The key of the List to trim.

    range

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

  • LTRIM

    Example usage:

    // keep first 4 elements
    client.send(.ltrim("myList", keepingIndices: 0..<4))
    
    // keep all but the last 3 elements
    client.send(.ltrim("myList", keepingIndices: 0..<(-3)))
    

    Declaration

    Swift

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

    Parameters

    key

    The key of the List to trim.

    range

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

  • Declaration

    Swift

    public static func rpop(from key: RedisKey) -> RedisCommand<RESPValue?>

    Parameters

    key

    The key of the list to pop from.

  • Declaration

    Swift

    public static func rpoplpush(from source: RedisKey, to dest: RedisKey) -> RedisCommand<RESPValue?>

    Parameters

    source

    The key of the list to pop from.

    dest

    The key of the list to push to.

  • RPUSH

    Note

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

    Declaration

    Swift

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

    Parameters

    elements

    The values to push into the list.

    key

    The key of the list.

  • RPUSH

    Note

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

    Declaration

    Swift

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

    Parameters

    elements

    The values to push into the list.

    key

    The key of the list.

  • RPUSHX

    Note

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

    Declaration

    Swift

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

    Parameters

    element

    The value to try and push into the list.

    key

    The key of the list.

  • Declaration

    Swift

    public static func swapdb(_ first: Int, with second: Int) -> RedisCommand<Bool>

    Parameters

    first

    The index of the first database.

    second

    The index of the second database.

  • Declaration

    Swift

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

    Parameters

    elements

    The values to add to the set.

    key

    The key of the set to insert into.

  • Declaration

    Swift

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

    Parameters

    elements

    The values to add to the set.

    key

    The key of the set to insert into.

  • Declaration

    Swift

    public static func scard(of key: RedisKey) -> RedisCommand<Int>

    Parameters

    key

    The key of the set.

  • Declaration

    Swift

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

    Parameters

    keys

    The source sets to calculate the difference of.

  • Declaration

    Swift

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

    Parameters

    keys

    The source sets to calculate the difference of.

  • SDIFFSTORE

    Warning

    If the destination key already exists, its value will be overwritten.

    Declaration

    Swift

    public static func sdiffstore(as destination: RedisKey, sources keys: [RedisKey]) -> RedisCommand<Int>

    Parameters

    destination

    The key of the new set from the result.

    sources

    The list of source sets to calculate the difference of.

  • Declaration

    Swift

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

    Parameters

    keys

    The source sets to calculate the intersection of.

  • Declaration

    Swift

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

    Parameters

    keys

    The source sets to calculate the intersection of.

  • SINTERSTORE

    Warning

    If the destination key already exists, its value will be overwritten.

    Declaration

    Swift

    public static func sinterstore(as destination: RedisKey, sources keys: [RedisKey]) -> RedisCommand<Int>

    Parameters

    destination

    The key of the new set from the result.

    sources

    A list of source sets to calculate the intersection of.

  • Declaration

    Swift

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

    Parameters

    element

    The element to look for in the set.

    key

    The key of the set to look in.

  • SMEMBERS

    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.

    Declaration

    Swift

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

    Parameters

    key

    The key of the set.

  • Declaration

    Swift

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

    Parameters

    element

    The value to move from the source.

    sourceKey

    The key of the source set.

    destKey

    The key of the destination set.

  • Declaration

    Swift

    public static func spop(from key: RedisKey, max count: Int = 1) -> RedisCommand<[RESPValue]>

    Parameters

    key

    The key of the set.

    count

    The max number of elements to pop from the set.

  • SRANDMEMBER

    Example usage:

    // pull just 1 random element
    client.send(.srandmember(from: "my_key"))
    
    // pulls up to 3 elements, allowing duplicates
    client.send(.srandmember(from: "my_key", max: -3))
    
    // pulls up to 3 unique elements
    client.send(.srandmember(from: "my_key", max: 3))
    

    Declaration

    Swift

    public static func srandmember(from key: RedisKey, max count: Int = 1) -> RedisCommand<[RESPValue]>

    Parameters

    key

    The key of the set.

    count

    The max number of elements to select from the set.

  • Declaration

    Swift

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

    Parameters

    elements

    The values to remove from the set.

    key

    The key of the set to remove from.

  • Declaration

    Swift

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

    Parameters

    elements

    The values to remove from the set.

    key

    The key of the set to remove from.

  • Declaration

    Swift

    public static func sunion(of keys: [RedisKey]) -> RedisCommand<[RESPValue]>

    Parameters

    keys

    The source sets to calculate the union of.

  • Declaration

    Swift

    public static func sunion(of keys: RedisKey...) -> RedisCommand<[RESPValue]>

    Parameters

    keys

    The source sets to calculate the union of.

  • Declaration

    Swift

    public static func sunionstore(as destination: RedisKey, sources keys: [RedisKey]) -> RedisCommand<Int>

    Parameters

    destination

    The key of the new set from the result.

    sources

    A list of source sets to calculate the union of.

  • Declaration

    Swift

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

  • BZPOPMIN

    Warning

    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.

    Declaration

    Swift

    public static func bzpopmin(
        from key: RedisKey,
        timeout: TimeAmount = .seconds(0)
    ) -> RedisCommand<(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.

  • BZPOPMIN

    Warning

    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.

    Declaration

    Swift

    public static func bzpopmin(
        from keys: [RedisKey],
        timeout: TimeAmount = .seconds(0)
    ) -> RedisCommand<(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.

  • BZPOPMIN

    Warning

    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.

    Declaration

    Swift

    public static func bzpopmin(
        from keys: RedisKey...,
        timeout: TimeAmount = .seconds(0)
    ) -> RedisCommand<(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.

  • BZPOPMAX

    Warning

    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.

    Declaration

    Swift

    public static func bzpopmax(
        from key: RedisKey,
        timeout: TimeAmount = .seconds(0)
    ) -> RedisCommand<(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.

  • BZPOPMAX

    Warning

    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.

    Declaration

    Swift

    public static func bzpopmax(
        from keys: [RedisKey],
        timeout: TimeAmount = .seconds(0)
    ) -> RedisCommand<(String, 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.

  • BZPOPMAX

    Warning

    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.

    Declaration

    Swift

    public static func bzpopmax(
        from keys: RedisKey...,
        timeout: TimeAmount = .seconds(0)
    ) -> RedisCommand<(String, 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.

  • Declaration

    Swift

    @inlinable
    public static func zadd<Value: RESPValueConvertible>(
        _ element: (value: Value, score: Double),
        to key: RedisKey,
        inserting insertBehavior: RedisZaddInsertBehavior = .allElements,
        returning returnBehavior: RedisZaddReturnBehavior = .insertedElementsCount
    ) -> RedisCommand<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.

  • Declaration

    Swift

    @inlinable
    public static func zadd<Value: RESPValueConvertible>(
        _ elements: [(element: Value, score: Double)],
        to key: RedisKey,
        inserting insertBehavior: RedisZaddInsertBehavior = .allElements,
        returning returnBehavior: RedisZaddReturnBehavior = .insertedElementsCount
    ) -> RedisCommand<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.

  • Declaration

    Swift

    @inlinable
    public static func zadd<Value: RESPValueConvertible>(
        _ elements: (element: Value, score: Double)...,
        to key: RedisKey,
        inserting insertBehavior: RedisZaddInsertBehavior = .allElements,
        returning returnBehavior: RedisZaddReturnBehavior = .insertedElementsCount
    ) -> RedisCommand<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.

  • Declaration

    Swift

    public static func zcard(of key: RedisKey) -> RedisCommand<Int>

    Parameters

    key

    The key of the sorted set.

  • ZCOUNT

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

    // count elements with score of 3...10
    client.send(.zcount(of: "mySortedSet", withScoresBetween: (3, 10)))
    
    // count elements with score 3..<10
    client.send(.zcount(of: "mySortedSet", withScoresBetween: (3, .exclusive(10))))
    

    Declaration

    Swift

    public static func zcount(
        of key: RedisKey,
        withScoresBetween range: (min: RedisZScoreBound, max: RedisZScoreBound)
    ) -> RedisCommand<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.

  • ZCOUNT

    Example usage:

    // count of elements with at least score of 3, but no greater than 10
    client.send(.zcount(of: "mySortedSet", withScores: 3...10)
    

    Declaration

    Swift

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

    Parameters

    key

    The key of the SortedSet that will be counted.

    range

    The inclusive range of scores to filter elements to count.

  • ZCOUNT

    Example usage:

    // count of elements with at least score of 3, but less than 10
    client.send(.zcount(of: "mySortedSet", withScores: 3..<10)
    

    Declaration

    Swift

    public static func zcount(of key: RedisKey, withScores range: Range<Double>) -> RedisCommand<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.

  • Declaration

    Swift

    public static func zcount(of key: RedisKey, withMinimumScoreOf minScore: RedisZScoreBound) -> RedisCommand<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.

  • Declaration

    Swift

    public static func zcount(of key: RedisKey, withMaximumScoreOf maxScore: RedisZScoreBound) -> RedisCommand<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.

  • Declaration

    Swift

    @inlinable
    public static func zincrby<Value: RESPValueConvertible>(
        _ element: Value,
        in key: RedisKey,
        by amount: Double
    ) -> RedisCommand<Double>

    Parameters

    element

    The element to increment.

    key

    The key of the sorted set.

    amount

    The amount to increment this element’s score by.

  • ZINTERSTORE

    Warning

    This operation overwrites any value stored at the destination key.

    Declaration

    Swift

    public static func zinterstore(
        as destination: RedisKey,
        sources: [RedisKey],
        weights: [Int]? = nil,
        aggregateMethod aggregate: RedisSortedSetAggregateMethod? = nil
    ) -> RedisCommand<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.

  • ZLEXCOUNT

    Example usage:

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

    Warning

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

    Declaration

    Swift

    @inlinable
    public static func zlexcount<Value: CustomStringConvertible>(
        of key: RedisKey,
        withValuesBetween range: (min: RedisZLexBound<Value>, max: RedisZLexBound<Value>)
    ) -> RedisCommand<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.

  • ZLEXCOUNT

    Warning

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

    Declaration

    Swift

    @inlinable
    public static func zlexcount<Value: CustomStringConvertible>(
        of key: RedisKey,
        withMinimumValueOf minValue: RedisZLexBound<Value>
    ) -> RedisCommand<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.

  • ZLEXCOUNT

    Warning

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

    Declaration

    Swift

    @inlinable
    public static func zlexcount<Value: CustomStringConvertible>(
        of key: RedisKey,
        withMaximumValueOf maxValue: RedisZLexBound<Value>
    ) -> RedisCommand<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.

  • Declaration

    Swift

    public static func zpopmax(from key: RedisKey) -> RedisCommand<(RESPValue, Double)?>

    Parameters

    key

    The key identifying the sorted set in Redis.

  • Declaration

    Swift

    public static func zpopmax(from key: RedisKey, max count: Int) -> RedisCommand<[(RESPValue, Double)]>

    Parameters

    key

    The key identifying the sorted set in Redis.

    count

    The max number of elements to pop from the set.

  • Declaration

    Swift

    public static func zpopmin(from key: RedisKey) -> RedisCommand<(RESPValue, Double)?>

    Parameters

    key

    The key identifying the sorted set in Redis.

  • Declaration

    Swift

    public static func zpopmin(from key: RedisKey, max count: Int) -> RedisCommand<[(RESPValue, Double)]>

    Parameters

    key

    The key identifying the sorted set in Redis.

    count

    The max number of elements to pop from the set.

  • Declaration

    Swift

    @inlinable
    public static func zrange<T>(
        from key: RedisKey,
        firstIndex: Int,
        lastIndex: Int,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    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.

    resultOption

    What information should be returned in the result?

  • ZRANGE

    Precondition

    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:resultOption:) instead.

    Important

    This treats the SortedSet as ordered from low to high.

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

    Declaration

    Swift

    @inlinable
    public static func zrange<T>(
        from key: RedisKey,
        indices range: ClosedRange<Int>,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    Parameters

    key

    The key of the SortedSet to return elements from.

    range

    The range of inclusive indices of elements to get.

    resultOption

    What information should be returned in the result?

  • ZRANGE

    Precondition

    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:returning:).

    Declaration

    Swift

    @inlinable
    public static func zrange<T>(
        from key: RedisKey,
        indices range: Range<Int>,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    Parameters

    key

    The key of the SortedSet to return elements from.

    range

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

    resultOption

    What information should be returned in the result?

  • ZRANGE

    Important

    This treats the SortedSet as ordered from low to high.

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

    Declaration

    Swift

    @inlinable
    public static func zrange<T>(
        from key: RedisKey,
        fromIndex index: Int,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    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.

    resultOption

    What information should be returned in the result?

  • ZRANGE

    Important

    This treats the SortedSet as ordered from low to high.

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

    Declaration

    Swift

    @inlinable
    public static func zrange<T>(
        from key: RedisKey,
        throughIndex index: Int,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    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.

    resultOption

    What information should be returned in the result?

  • ZRANGE

    Important

    This treats the SortedSet as ordered from low to high.

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

    Declaration

    Swift

    @inlinable
    public static func zrange<T>(
        from key: RedisKey,
        upToIndex index: Int,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    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.

    resultOption

    What information should be returned in the result?

  • 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 static func zrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withValuesBetween range: (min: RedisZLexBound<Value>, max: RedisZLexBound<Value>),
        limitBy limit: (offset: Int, count: Int)? = nil
    ) -> RedisCommand<[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.

  • 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 static func zrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withMinimumValueOf minValue: RedisZLexBound<Value>,
        limitBy limit: (offset: Int, count: Int)? = nil
    ) -> RedisCommand<[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

  • 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 static func zrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withMaximumValueOf maxValue: RedisZLexBound<Value>,
        limitBy limit: (offset: Int, count: Int)? = nil
    ) -> RedisCommand<[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

  • 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 static func zrevrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withValuesBetween range: (min: RedisZLexBound<Value>, max: RedisZLexBound<Value>),
        limitBy limit: (offset: Int, count: Int)? = nil
    ) -> RedisCommand<[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.

  • 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 static func zrevrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withMinimumValueOf minValue: RedisZLexBound<Value>,
        limitBy limit: (offset: Int, count: Int)? = nil
    ) -> RedisCommand<[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

  • 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 static func zrevrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withMaximumValueOf maxValue: RedisZLexBound<Value>,
        limitBy limit: (offset: Int, count: Int)? = nil
    ) -> RedisCommand<[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

  • ZRANGEBYSCORE

    Important

    This treats the SortedSet as ordered from low to high.

    For the inverse, see zrevrangebyscore(from:withScoresBetween:limitBy:returning:).

    Declaration

    Swift

    @inlinable
    public static func zrangebyscore<T>(
        from key: RedisKey,
        withScoresBetween range: (min: RedisZScoreBound, max: RedisZScoreBound),
        limitBy limit: (offset: Int, count: Int)? = nil,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    Parameters

    key

    The key of the SortedSet.

    range

    The min and max score bounds to filter elements by.

    limit

    The optional offset and count of elements to query.

    resultOption

    What information should be returned in the result?

  • ZRANGEBYSCORE

    Important

    This treats the SortedSet as ordered from low to high.

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

    Declaration

    Swift

    @inlinable
    public static func zrangebyscore<T>(
        from key: RedisKey,
        withScores range: ClosedRange<Double>,
        limitBy limit: (offset: Int, count: Int)? = nil,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    Parameters

    key

    The key of the SortedSet.

    range

    The inclusive range of scores to filter elements by.

    limit

    The optional offset and count of elements to query.

    resultOption

    What information should be returned in the result?

  • ZRANGEBYSCORE

    Important

    This treats the SortedSet as ordered from low to high.

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

    Declaration

    Swift

    @inlinable
    public static func zrangebyscore<T>(
        from key: RedisKey,
        withScores range: Range<Double>,
        limitBy limit: (offset: Int, count: Int)? = nil,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    Parameters

    key

    The key of the SortedSet.

    range

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

    limit

    The optional offset and count of elements to query.

    resultOption

    What information should be returned in the result?

  • ZRANGEBYSCORE

    Important

    This treats the SortedSet as ordered from low to high.

    For the inverse, see zrevrangebyscore(from:withMinimumScoreOf:limitBy:returning:).

    Declaration

    Swift

    @inlinable
    public static func zrangebyscore<T>(
        from key: RedisKey,
        withMinimumScoreOf minScore: RedisZScoreBound,
        limitBy limit: (offset: Int, count: Int)? = nil,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    Parameters

    key

    The key of the SortedSet.

    range

    The minimum score bound an element in the SortedSet should have to be included in the response.

    limit

    The optional offset and count of elements to query.

    resultOption

    What information should be returned in the result?

  • ZRANGEBYSCORE

    Important

    This treats the SortedSet as ordered from low to high.

    For the inverse, see zrevrangebyscore(from:withMaximumScoreOf:limitBy:returning:).

    Declaration

    Swift

    @inlinable
    public static func zrangebyscore<T>(
        from key: RedisKey,
        withMaximumScoreOf maxScore: RedisZScoreBound,
        limitBy limit: (offset: Int, count: Int)? = nil,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    Parameters

    key

    The key of the SortedSet.

    range

    The maximum score bound an element in the SortedSet should have to be included in the response.

    limit

    The optional offset and count of elements to query.

    resultOption

    What information should be returned in the result?

  • ZRANK

    Important

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

    For the inverse, see zrevrank(of:in:).

    Declaration

    Swift

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

    Parameters

    element

    The element in the sorted set to search for.

    key

    The key of the sorted set to search.

  • Declaration

    Swift

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

    Parameters

    elements

    The values to remove from the sorted set.

    key

    The key of the sorted set.

  • Declaration

    Swift

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

    Parameters

    elements

    The values to remove from the sorted set.

    key

    The key of the sorted set.

  • ZREMRANGEBYLEX

    Warning

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

    Declaration

    Swift

    @inlinable
    public static func zremrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withValuesBetween range: (min: RedisZLexBound<Value>, max: RedisZLexBound<Value>)
    ) -> RedisCommand<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.

  • ZREMRANGEBYLEX

    Warning

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

    Declaration

    Swift

    @inlinable
    public static func zremrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withMinimumValueOf minValue: RedisZLexBound<Value>
    ) -> RedisCommand<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.

  • ZREMRANGEBYLEX

    Warning

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

    Declaration

    Swift

    @inlinable
    public static func zremrangebylex<Value: CustomStringConvertible>(
        from key: RedisKey,
        withMaximumValueOf maxValue: RedisZLexBound<Value>
    ) -> RedisCommand<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.

  • Declaration

    Swift

    public static func zremrangebyrank(from key: RedisKey, firstIndex: Int, lastIndex: Int) -> RedisCommand<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.

  • ZREMRANGEBYRANK

    Precondition

    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 static func zremrangebyrank(from key: RedisKey, indices range: ClosedRange<Int>) -> RedisCommand<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    range

    The range of inclusive indices of elements to remove.

  • ZREMRANGEBYRANK

    Precondition

    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 static func zremrangebyrank(from key: RedisKey, indices range: Range<Int>) -> RedisCommand<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    range

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

  • Declaration

    Swift

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

    Parameters

    key

    The key of the SortedSet to remove elements from.

    index

    The index of the first element that will be removed.

  • Declaration

    Swift

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

    Parameters

    key

    The key of the SortedSet to remove elements from.

    index

    The index of the last element that will be removed.

  • ZREMRANGEBYRANK

    Warning

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

    Declaration

    Swift

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

    Parameters

    key

    The key of the SortedSet to remove elements from.

    index

    The index of the last element to not remove.

  • Declaration

    Swift

    public static func zremrangebyscore(
        from key: RedisKey,
        withScoresBetween range: (min: RedisZScoreBound, max: RedisZScoreBound)
    ) -> RedisCommand<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    range

    The min and max score bounds to filter elements by.

  • Declaration

    Swift

    public static func zremrangebyscore(from key: RedisKey, withScores range: ClosedRange<Double>) -> RedisCommand<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    range

    The inclusive range of scores to filter elements by.

  • Declaration

    Swift

    public static func zremrangebyscore(from key: RedisKey, withScores range: Range<Double>) -> RedisCommand<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    range

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

  • Declaration

    Swift

    public static func zremrangebyscore(from key: RedisKey, withMinimumScoreOf minScore: RedisZScoreBound) -> RedisCommand<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    minScore

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

  • Declaration

    Swift

    public static func zremrangebyscore(from key: RedisKey, withMaximumScoreOf maxScore: RedisZScoreBound) -> RedisCommand<Int>

    Parameters

    key

    The key of the SortedSet to remove elements from.

    minScore

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

  • ZREVRANGE

    Important

    This treats the SortedSet as ordered from high to low.

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

    Declaration

    Swift

    @inlinable
    public static func zrevrange<T>(
        from key: RedisKey,
        firstIndex: Int,
        lastIndex: Int,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    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.

    resultOption

    What information should be returned in the result?

  • ZREVRANGE

    Precondition

    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:returning:).

    Declaration

    Swift

    @inlinable
    public static func zrevrange<T>(
        from key: RedisKey,
        indices range: ClosedRange<Int>,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    Parameters

    key

    The key of the SortedSet to return elements from.

    range

    The range of inclusive indices of elements to get.

    resultOption

    What information should be returned in the result?

  • ZREVRANGE

    Precondition

    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:returning:).

    Declaration

    Swift

    @inlinable
    public static func zrevrange<T>(
        from key: RedisKey,
        indices range: Range<Int>,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    Parameters

    key

    The key of the SortedSet to return elements from.

    range

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

    resultOption

    What information should be returned in the result?

  • ZREVRANGE

    Important

    This treats the SortedSet as ordered from high to low.

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

    Declaration

    Swift

    @inlinable
    public static func zrevrange<T>(
        from key: RedisKey,
        fromIndex index: Int,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    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.

    resultOption

    What information should be returned in the result?

  • ZREVRANGE

    Important

    This treats the SortedSet as ordered from high to low.

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

    Declaration

    Swift

    @inlinable
    public static func zrevrange<T>(
        from key: RedisKey,
        throughIndex index: Int,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    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.

    resultOption

    What information should be returned in the result?

  • ZREVRANGE

    Important

    This treats the SortedSet as ordered from high to low.

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

    Declaration

    Swift

    @inlinable
    public static func zrevrange<T>(
        from key: RedisKey,
        upToIndex index: Int,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    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.

    resultOption

    What information should be returned in the result?

  • ZREVRANGEBYSCORE

    Important

    This treats the SortedSet as ordered from high to low.

    For the inverse, see zrangebyscore(from:withScoresBetween:limitBy:returning:).

    Declaration

    Swift

    @inlinable
    public static func zrevrangebyscore<T>(
        from key: RedisKey,
        withScoresBetween range: (min: RedisZScoreBound, max: RedisZScoreBound),
        limitBy limit: (offset: Int, count: Int)? = nil,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    Parameters

    key

    The key of the SortedSet.

    range

    The min and max score bounds to filter elements by.

    limit

    The optional offset and count of elements to query.

    resultOption

    What information should be returned in the result?

  • ZREVRANGEBYSCORE

    Important

    This treats the SortedSet as ordered from high to low.

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

    Declaration

    Swift

    @inlinable
    public static func zrevrangebyscore<T>(
        from key: RedisKey,
        withScores range: ClosedRange<Double>,
        limitBy limit: (offset: Int, count: Int)? = nil,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    Parameters

    key

    The key of the SortedSet.

    range

    The inclusive range of scores to filter elements by.

    limit

    The optional offset and count of elements to query.

    resultOption

    What information should be returned in the result?

  • ZREVRANGEBYSCORE

    Important

    This treats the SortedSet as ordered from high to low.

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

    Declaration

    Swift

    @inlinable
    public static func zrevrangebyscore<T>(
        from key: RedisKey,
        withScores range: Range<Double>,
        limitBy limit: (offset: Int, count: Int)? = nil,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    Parameters

    key

    The key of the SortedSet.

    range

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

    limit

    The optional offset and count of elements to query.

    resultOption

    What information should be returned in the result?

  • ZREVRANGEBYSCORE

    Important

    This treats the SortedSet as ordered from high to low.

    For the inverse, see zrangebyscore(from:withMinimumScoreOf:limitBy:returning:).

    Declaration

    Swift

    @inlinable
    public static func zrevrangebyscore<T>(
        from key: RedisKey,
        withMinimumScoreOf minScore: RedisZScoreBound,
        limitBy limit: (offset: Int, count: Int)? = nil,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    Parameters

    key

    The key of the SortedSet.

    range

    The minimum score bound an element in the SortedSet should have to be included in the response.

    limit

    The optional offset and count of elements to query.

    resultOption

    What information should be returned in the result?

  • ZREVRANGEBYSCORE

    Important

    This treats the SortedSet as ordered from high to low.

    For the inverse, see zrangebyscore(from:withMaximumScoreOf:limitBy:returning:).

    Declaration

    Swift

    @inlinable
    public static func zrevrangebyscore<T>(
        from key: RedisKey,
        withMaximumScoreOf maxScore: RedisZScoreBound,
        limitBy limit: (offset: Int, count: Int)? = nil,
        returning resultOption: RedisZRangeResultOption<T>
    ) -> RedisCommand<T>

    Parameters

    key

    The key of the SortedSet.

    range

    The maximum score bound an element in the SortedSet should have to be included in the response.

    limit

    The optional offset and count of elements to query.

    resultOption

    What information should be returned in the result?

  • ZREVRANK

    Important

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

    For the inverse, see zrank(of:in:).

    Declaration

    Swift

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

    Parameters

    element

    The element in the sorted set to search for.

    key

    The key of the sorted set to search.

  • Declaration

    Swift

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

    Parameters

    element

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

    key

    The key of the sorted set.

  • ZUNIONSTORE

    Warning

    This operation overwrites any value stored at the destination key.

    Declaration

    Swift

    public static func zunionstore(
        as destination: RedisKey,
        sources: [RedisKey],
        weights: [Int]? = nil,
        aggregateMethod aggregate: RedisSortedSetAggregateMethod? = nil
    ) -> RedisCommand<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.

  • Declaration

    Swift

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