Skip to content

hummingbird-project/hummingbird-valkey

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 a Swift driver for Valkey/Redis. Currently HummingbirdValkey consists of driver for the Hummingbird persist framework.

Usage

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

About

Hummingbird integration with Valkey and Redis

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 2

  •  
  •