Swiftpack.co - michaelvanstraten/swifty-redis as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by michaelvanstraten.
michaelvanstraten/swifty-redis v0.1.2
SwiftyRedis is a high level async redis library for Swift.
⭐️ 4
🕓 14 weeks ago
iOS macOS watchOS tvOS macCatalyst
.package(url: "https://github.com/michaelvanstraten/swifty-redis.git", from: "v0.1.2")


SwiftyRedis is a high level async redis library for Swift. It is partially rewritten and heavily inspired by the redis-rs rust crate. It provides convenient access to all Redis functionality through a very flexible but low-level API. It has a customizable type conversion protocol so that any operation can return results in just the type you are expecting. This makes for a very pleasant development experience.

Basic usage

let client = RedisClient(.init("localhost"))
let connection = try await client.get_connection()

let value: String = try await connection.hget("myhash", "field1")


The Documentation is available here or under the link in the about section on the right.


I personally use xcode and vs-code for this project but i think any other IDE will also do as long as the swift compiler is installed.


Do to the fact that redis offers 240 (stand July 2022) commands i wrote a small python script which generates the corresponding functions for us. The script automatically pulls the latest updates from the redis github repo and parses the json files specifying every command, located under src/commands, into a Swift implementation.

To rerun the auto-generation execute the generate-commands.py script located in the Sources/Autogen directory. The resulting Swift files will be located in the Sources/SwiftyRedis/Autogen/Commands directory. This should automatically implement new commands that were not present at this point in time.

If anything goes wrong and the script doesn't implement a commands correctly, you can specify the name of the function in the commands_to_ignore.json file located in the Sources/Autogen/config directory. Important to note is that you must specify the function name that would be generated not the name of the command, this is for eas of development purposes so you don't have to lookup the actual command name.

There is also a formatting_config.json file located in the Sources/Autogen/config directory. This file holds a configuration which is passed to swift-format which is is responsible for formatting the generated Swift files.


Stars: 4
Last commit: 2 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics