Motivation: During proposal review, and while working within the codebase, several issues were identified with how `RedisConnection` was architectured. Modifications: - Change implementation of `RedisConnection` in some areas for new logic of internal `ConnectionState` - Change behavior of logging in a few places - The initializer for `RedisConnection` is now **internal** - How users can override the default `ClientBootstrap` for a connection is by passing an instance to the `.connect` static method - Change unit tests to inherit from a common XCTestCase class that handles creation and cleanup of `RedisConnection` in tests - Remove Redis namespace enum Result: The API for `RedisConnection` should be much simpler, with the implementation being less buggy. This resolves issues #49, #54, and #57.
3.0 KiB
| The GitHub repository is a read-only mirror of the GitLab repository. For issues and merge requests, please visit GitLab. |
|---|
Swift Redis NIO Client
A non-blocking Swift client for Redis built on top of SwiftNIO.
This package defines everything you need to work with Redis through the Redis Seralization Protocol (RESP).
RedisNIO is part of the Swift on Server Working Group ecosystem.
| Proposal | Pitch | Discussion | Review | Vote |
|---|---|---|---|---|
| SSWG-0004 | 2019-01-07 | 2019-04-01 | TBD | TBD |
📦 Installation
To install RedisNIO, just add the package as a dependency in your Package.swift
dependencies: [
.package(url: "https://github.com/Mordil/swift-redis-nio-client.git", from: "1.0.0-alpha.4")
]
and run the following command: swift package resolve
⚡ Getting Started
RedisNIO is quick to use - all you need is an EventLoop from SwiftNIO.
import NIO
import RedisNIO
let eventLoop: EventLoop = ...
let connection = RedisConnection.connect(
to: try .init(ipAddress: "127.0.0.1", 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")
📕 Documentation
API Documentation is generated every time a new release is published.
The latest version's docs are always available at https://mordil.gitlab.io/swift-redis-nio-client
🚧 Contributing
Check out CONTRIBUTING.md for more information on how to help with RedisNIO.
It is highly recommended to use Docker to install Redis locally.
docker run -d -p 6379:6379 --name redis redis:5
Otherwise, install Redis directly on your machine from Redis.io.