package redis-async
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=887f10006f90b3d37b01e715dad466d5b56f9b58f20f217c69df825f23829d90
Description
A client library for Redis versions 6 and higher.
Provides a strongly-typed API with transparent (de)serialization for application-defined types.
Supports client tracking and internally uses the RESP3 protocol.
Added to opam-repository:
README
Redis Async
A Redis client library for OCaml Async applications. Provides a strongly-typed API with transparent (de)serialization for application-defined types. Includes support for client tracking.
Compatible with Redis versions 6 and higher. Internally, implements the RESP3 protocol.
Example Usage
Here are a few basic examples. Please see the included tests for additional detail and features.
Plain
Redis natively works with plain strings for many commands. Users of other Redis clients will be most familiar this style of interaction.
open Core
open Async
open Deferred.Or_error.Let_syntax
module Redis = Redis.Make (Redis.Bulk_io.String) (Redis.Bulk_io.String) in
let%bind redis =
Redis.create
~where_to_connect:
(Tcp.Where_to_connect.of_host_and_port
(Host_and_port.create ~host:"localhost" ~port:6379))
()
in
let%map reply = Redis.echo redis "Hello, world!" in
print_endline replyTypeful
Application-defined types can be used directly as Redis keys and values. Convenience functors that implement the required (de)serialization for Stringable and Binable types are provided.
open Core
open Async
open Deferred.Or_error.Let_syntax
module Key = struct
module T = struct
type t = { name : string }
let to_string { name } = name
let of_string name = { name }
end
include T
include Redis.Bulk_io.Make_stringable (T)
end
module Value = struct
module T = struct
type t =
{ color : string
; number : int
}
[@@deriving bin_io, sexp]
end
include T
include Redis.Bulk_io.Make_binable (T)
end
module Redis = Redis.Make (Key) (Value) in
let%bind redis =
Redis.create
~where_to_connect:
(Tcp.Where_to_connect.of_host_and_port
(Host_and_port.create ~host:"localhost" ~port:6379))
()
in
let key = { Key.name = "Jane" } in
let value = { Value.color = "blue"; number = 42 } in
let%bind () = Redis.set redis key value in
let%map value = Redis.get redis key in
print_s ([%sexp_of: Value.t option] value)
Dependencies (7)
Dev Dependencies
None
Used by
None
Conflicts
None
Build status
Results of building redis-async with each compiler on check.ci.ocaml.org, run of against opam-repository 7cdc698. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| v0.17.0 (this version) | n/a | n/a | good | good | good |
| v0.16.0 | n/a | good | good | n/a | n/a |
| v0.15.0 | good | good | n/a | n/a | n/a |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure