mirror of
https://github.com/swift-server/RediStack.git
synced 2026-06-02 07:37:33 +00:00
Motivation:
The SSWG has identified a fast approaching reality of namespace clashes in SPM within the ecosystem and has proposed a rule on names that `NIORedis` no longer complies with.
Modifications:
All references to `NIORedis` have been switched to `RedisNIO` as this module name is unique (at least within GitHub's public repositories).
The goals for this name are as follows:
1. To indicate that this is a Redis client library that is built with SwiftNIO
2. That it is a lower level library, as it directly exposes SwiftNIO as an implementation detail
2a. The idea being that a higher level library (`Redis`) will be used, and to "go one level deeper" in the stack, you append the "deeper" `NIO` postfix
3. It follows a naming pattern adopted by Vapor who has expressed their desire to adopt this library as their Redis implementation
Result:
A repository, package name, and module name that are unique across GitHub's public repositories that achives the goals outlined above.
58 lines
2.3 KiB
Markdown
58 lines
2.3 KiB
Markdown
[](https://www.apache.org/licenses/LICENSE-2.0.html)
|
|
[](https://circleci.com/gh/Mordil/nio-redis/tree/master)
|
|
[](https://swift.org)
|
|
[](https://redis.io/download)
|
|
|
|
# Swift Redis NIO Client
|
|
|
|
A non-blocking Swift client for [Redis](https://redis.io/) built on top of [SwiftNIO](https://github.com/apple/swift-nio).
|
|
|
|
This package defines everything you need to work with Redis through the [**Re**dis **S**eralization **P**rotocol (RESP)](https://redis.io/topics/protocol).
|
|
|
|
* Swift Server Working Group Proposal: [SSWG-0004](https://github.com/swift-server/sswg/blob/d391da355718a8f396ef86b3563910089d5e5992/proposals/0004-nio-redis.md)
|
|
* [Pitch thread](https://forums.swift.org/t/swiftnio-redis-client/19325)
|
|
* [Discussion Thread](https://forums.swift.org/t/discussion-nioredis-nio-based-redis-driver/22455/)
|
|
|
|
## Installation
|
|
|
|
To install `RedisNIO`, just add the package as a dependency in your [**Package.swift**](https://github.com/apple/swift-package-manager/blob/master/Documentation/PackageDescriptionV4.md#dependencies)
|
|
|
|
```swift
|
|
dependencies: [
|
|
.package(url: "https://github.com/Mordil/swift-redis-nio-client.git", .upToNextMinor(from: "0.8.0")
|
|
]
|
|
```
|
|
|
|
and run the following command: `swift package resolve`
|
|
|
|
## Getting Started
|
|
|
|
`RedisNIO` is ready to use right after installation.
|
|
|
|
```swift
|
|
import RedisNIO
|
|
|
|
let connection = Redis.makeConnection(
|
|
to: try .init(ipAddress: "127.0.0.1", port: 6379),
|
|
password: "my_pass"
|
|
).wait()
|
|
|
|
let result = try connection.set("my_key", to: "some value")
|
|
.flatMap { return connection.get("my_key" }
|
|
.wait()
|
|
|
|
print(result) // Optional("some value")
|
|
```
|
|
|
|
## Contributing
|
|
|
|
Check out [CONTRIBUTING.md](CONTRIBUTING.md) for more information on how to help with RedisNIO.
|
|
|
|
It is highly recommended to use [Docker](https://docker.com) to install Redis locally.
|
|
|
|
```bash
|
|
docker run -d -p 6379:6379 --name redisnio redis:5
|
|
```
|
|
|
|
Otherwise, install Redis directly on your machine from [Redis.io](https://redis.io/download).
|