Classes

The following classes are available globally.

  • Handles incoming byte messages from Redis and decodes them according to the Redis Serialization Protocol (RESP).

    See NIO.ByteToMessageDecoder, RESPTranslator and https://redis.io/topics/protocol

    See more

    Declaration

    Swift

    public final class RedisByteDecoder : ByteToMessageDecoder
  • An object that operates in a First In, First Out (FIFO) request-response cycle.

    RedisCommandHandler is a NIO.ChannelDuplexHandler that sends RedisCommand instances to Redis, and fulfills the command’s NIO.EventLoopPromise as soon as a RESPValue response has been received from Redis.

    See more

    Declaration

    Swift

    public final class RedisCommandHandler
    extension RedisCommandHandler: ChannelInboundHandler
    extension RedisCommandHandler: ChannelOutboundHandler
  • Encodes outgoing RESPValue data into a raw ByteBuffer according to the Redis Serialization Protocol (RESP).

    See NIO.MessageToByteEncoder, RESPTranslator, and https://redis.io/topics/protocol

    See more

    Declaration

    Swift

    public final class RedisMessageEncoder : MessageToByteEncoder
  • A concrete RedisClient implementation that represents an individual connection to a Redis database instance.

    For basic setups, you will just need a NIO.SocketAddress and a NIO.EventLoop and perhaps a password.

    let eventLoop: EventLoop = ...
    let connection = RedisConnection.connect(
        to: try .makeAddressResolvingHost("my.redis.url", port: RedisConnection.defaultPort),
        on: eventLoop
    ).wait()
    
    let result = try connection.set("my_key", to: "some value")
        .flatMap { return connection.get("my_key") }
        .wait()
    
    print(result) // Optional("some value")
    

    Note: wait() is used in the example for simplicity. Never call wait() on an event loop.

    See NIO.SocketAddress, NIO.EventLoop, and RedisClient

    See more

    Declaration

    Swift

    public final class RedisConnection : RedisClient
  • A RedisConnectionPool is an implementation of RedisClient backed by a pool of connections to Redis, rather than a single one.

    RedisConnectionPool uses a pool of connections on a single EventLoop to manage its activity. This pool may vary in size and strategy, including how many active connections it tries to manage at any one time and how it responds to demand for connections beyond its upper limit.

    Note that RedisConnectionPool is entirely thread-safe, even though all of its connections belong to a single EventLoop: if callers call the API from a different EventLoop (or from no EventLoop at all) RedisConnectionPool will ensure that the call is dispatched to the correct loop.

    See more

    Declaration

    Swift

    public class RedisConnectionPool
    extension RedisConnectionPool: RedisClient
  • A specialized wrapper class for working with Metrics.Gauge objects for the purpose of an incrementing or decrementing count of active Redis connections.

    See more

    Declaration

    Swift

    public class ActiveConnectionGauge