-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved readme: changed wording, added features section, etc
- Loading branch information
1 parent
4f343b6
commit fdf2018
Showing
1 changed file
with
27 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,45 @@ | ||
# SwiftyRedis | ||
# SwiftyRedis | ||
|
||
SwiftyRedis is a high level async redis library for Swift. It is partially rewritten and heavily inspired by the [redis-rs](https://github.com/redis-rs/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. | ||
SwiftyRedis is a powerful asynchronous Redis library for Swift that simplifies interaction with Redis databases. Drawing inspiration from the [redis-rs](https://github.com/redis-rs/redis-rs) Rust crate, SwiftyRedis offers a high-level interface to Redis functionality, while also allowing for low-level flexibility. It's designed to enhance your development experience by providing customizable type conversions and leveraging modern async-await patterns. | ||
|
||
## Basic usage | ||
## Basic Usage | ||
|
||
```swift | ||
import SwiftyRedis | ||
|
||
let client = RedisClient(.init("localhost")) | ||
let connection = try await client.get_connection() | ||
let connection = try await client.getConnection() | ||
|
||
let value: String = try await connection.hget("myhash", "field1") | ||
``` | ||
|
||
## Features and Enhancements | ||
|
||
- [x] Implementation of over 240 Redis commands | ||
- [x] Seamless type conversion protocol for user-friendly results | ||
- [x] Utilization of modern and intuitive async-await design | ||
- [x] Simplified builder interface for constructing custom commands | ||
- [x] Built-in Pub/Sub support | ||
- [ ] Upcoming: Cluster support | ||
- [ ] Upcoming: RedisJSON implementation | ||
- [ ] Upcoming: RedisTimeSeries implementation | ||
|
||
## Documentation | ||
|
||
The Documentation is available [here](https://michaelvanstraten.github.io/swifty-redis/documentation/swiftyredis/) or under the link in the about section on the right. | ||
Comprehensive documentation is available [here](https://michaelvanstraten.github.io/swifty-redis/documentation/swiftyredis/), or you can access it via the link in the "About" section on the right. | ||
|
||
## Development Environment | ||
|
||
## Contribution | ||
While I personally use Xcode and neovim for this project, you can choose any IDE of your preference as long as you have the [Swift compiler](https://www.swift.org/getting-started/) installed. | ||
|
||
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](https://www.swift.org/getting-started/) is installed. | ||
### Auto-Generation | ||
|
||
### Autogen | ||
Given Redis offers an extensive set of 240+ commands, I've developed a Python script for auto-generating corresponding Swift functions. This script extracts the latest command information from the [Redis GitHub repository](https://github.com/redis/redis), parsing JSON files located under `src/commands`. To rerun this auto-generation process, execute the `generate-commands.py` script found in the `Sources/Autogen` directory. The resulting Swift files will be placed in the `Sources/SwiftyRedis/Autogen/Commands` directory. This mechanism ensures that new commands introduced by Redis will be automatically supported. | ||
|
||
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](https://github.com/redis/redis) and parses the json files specifying every command, located under `src/commands`, into a Swift implementation. | ||
In case of any issues during command implementation, you can specify function names in the `commands_to_ignore.json` file situated in the `Sources/Autogen/config` directory. It's worth noting that you should use the function names that would be generated, not the command names themselves. This approach simplifies development by obviating the need to look up actual command names. | ||
|
||
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. | ||
Furthermore, a `formatting_config.json` file in the `Sources/Autogen/config` directory stores a configuration utilized by [swift-format](https://github.com/apple/swift-format), responsible for formatting generated Swift files. | ||
|
||
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. | ||
Feel free to contribute to the project and enhance this library's functionality! | ||
|
||
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](https://github.com/apple/swift-format) which is is responsible for formatting the generated Swift files. | ||
**Note:** The information provided in this readme reflects the state as of August 2023. |