An open API service indexing awesome lists of open source software.

https://github.com/hummingbird-project/hummingbird-valkey

Hummingbird integration with Valkey and Redis
https://github.com/hummingbird-project/hummingbird-valkey

hummingbird redis swift-on-server valkey

Last synced: 27 days ago
JSON representation

Hummingbird integration with Valkey and Redis

Awesome Lists containing this project

README

          













# Hummingbird Valkey/Redis Interface

Valkey is an open source, in-memory data structure store, used as a database, cache, and message broker.

This is the Hummingbird interface to the [valkey-swift library](https://github.com/valkey-io/valkey-swift.git) a Swift driver for Valkey/Redis. Currently HummingbirdValkey consists of driver for the Hummingbird persist framework.

## Usage

```swift
import Hummingbird
import HummingbirdValkey

let valkey = ValkeyClient(.hostname(valkeyHostname, port: 6379), logger: Logger(label: "Valkey"))
let persist = ValkeyPersistDriver(client: valkeyClient)

// create router and add a GET /valkey/{key} and PUT /valkey/{key} routes
let router = Router()
router.get("valkey/{key}") { request, context -> String? in
let key = try context.parameters.require("key")
return try await persist.get(key: .init(key), as: String.self)
}
router.put("valkey/{key}") { request, context in
let key = try context.parameters.require("key")
let value = try request.uri.queryParameters.require("value")
try await persist.set(key: key, value: value)
return HTTPResponse.Status.ok
}
// create application using router
var app = Application(
router: router,
configuration: .init(address: .hostname("127.0.0.1", port: 8080))
)
app.addServices(valkey)
// run hummingbird application
try await app.runService()
```

## Documentation

Reference documentation for HummingbirdValkey can be found [here](https://docs.hummingbird.codes/2.0/documentation/hummingbirdvalkey)