nozeio/swift-nio-redis-client
SwiftNIO Redis is a Swift package that contains a high performance
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/NozeIO/swift-nio-redis-client.git",
from: "0.10.0")
],
targets: [
.target(name: "MyClientTool",
dependencies: [ "Redis" ])
]
)Using the Redis client module
The Redis client module is modeled after the Node.js node_redis module, but it also supports NIO like Promise/Future based methods in addition to the Node.js (err,result) style callbacks. Choose your poison.
Simple KVS use example:
import Redis
let client = Redis.createClient()
client.set ("counter", 0, expire: 2)
client.incr("counter", by: 10)
client.get ("counter") { err, value in
print("Reply:", value)
}
client.keys("*") { err, reply in
guard let keys = reply else { return print("got no keys!") }
print("all keys in store:", keys.joined(separator: ","))
}Using NIO Promises:
client
.set ("counter", 0, expire: 2)
.then {
client.incr("counter", by: 10)
}
.then {
client.get("counter")
}
.map {
print("counter is:", $0)
}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.
The Redis client module has a few more open ends, but seems to work fine.
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: nozeio/swift-nio-redis-client
Default branch: main
README: README.md