swiftnioextras/swift-nio-redis
SwiftNIO Redis is a Swift package that contains a high performance
Performance
This implementation is focused on performance. It tries to reuse NIO ByteBuffers as much as possible to avoid copies.
The parser is based on a state machine, not on a buffering ByteToMessageDecoder/Encoder. That doesn't make it nice, but efficient ;-)
Importing the module using Swift Package Manager
An example Package.swift importing the necessary modules:
// swift-tools-version:5.0
import PackageDescription
let package = Package(
name: "RedisTests",
dependencies: [
.package(url: "https://github.com/SwiftNIOExtras/swift-nio-redis.git",
from: "0.9.2")
],
targets: [
.target(name: "MyProtocolTool",
dependencies: [ "NIORedis" ])
]
)Using the SwiftNIO Redis protocol handler
The RESP protocol is implemented as a regular ChannelHandler, similar to NIOHTTP1. It takes incoming ByteBuffer data, parses that, and emits RESPValue items. Same the other way around, the user writes RESPValue (or RESPEncodable) objects, and the handler renders such into ByteBuffers.
The NIORedis module has a litte more information.
To add the RESP handler to a NIO Channel pipeline, the configureRedisPipeline method is called, e.g.:
import NIORedis
bootstrap.channelInitializer { channel in
channel.pipeline
.configureRedisPipeline()
.then { ... }
}Status
The protocol implementation is considered complete. There are a few open ends in the telnet variant, yet the regular binary protocol is considered done.
Who
Brought to you by ZeeZide. We like feedback, GitHub stars, cool contract work, presumably any form of praise you can think of.
Package Metadata
Repository: swiftnioextras/swift-nio-redis
Default branch: main
README: README.md