package orewa

  1. Overview
  2. Docs
Async-friendly Redis client


Dune Dependency






Async-friendly Redis client

Orewa is a Redis client designed with cooperative multithreading in mind, thus operations are non-blocking by default.

It also features an OCaml-friendly Redis API wrapping the stringly constructs of the Redis commands into a more typed and less fragile interface that does its best to provide a pleasant interface.

Published: 19 Oct 2019



俺は - an Async friendly Redis binding in pure OCaml.


It is availaible on OPAM, just

opam install orewa

and off you go! No need to install any native libraries or other dependencies.


To connect to a Redis server use Orewa.connect which will return a handle to a connection. From here you can use all the implemented Redis commands in Orewa.* and also close the connection with Orewa.close. Or just use Orewa.with_connection to handle connection handling for you.

Orewa opts in to offering an OCaml-centric API, so the commands map to functions and these take typed arguments. So instead of distinguishing between seconds and millisecond variants, in Orewa both are represented by a time span type. Different options to commands are represented by ADTs, to avoid constructing invalid commands. The results are mapped into the most fitting OCaml data types. Orewa also avoids exceptions, so the signature will tell you exactly which error types are expected.


The integration test in src/integration/ attempts to test all implemented commands, so it demonstrates how each of them can be used.


The API documentation of the current release is available online. The naming of the functions follows the naming of Redis commands so it is simple to adapt from the Redis docs to OCaml.


Currently all commands from the string category in Redis 5 are implemented. Over time this set is meant to be expanded. If you need support for a specific command, submit a pull request.

For a very preliminary draft of what could be coming over time here's a list of ideas:

  1. Most (all?) sensible Redis commands

  2. Transactions in Redis

  3. Cluster support, maybe. Unlikely to happen any time soon.

Dependencies (5)

  1. ppx_deriving >= "4.2"
  2. ppx_let >= "v0.11"
  3. dune >= "1.4"
  4. core >= "v0.11"
  5. async >= "v0.11"

Dev Dependencies (2)

  1. alcotest-async with-test & >= "0.8.2"
  2. alcotest with-test & >= "0.8.4"

Used by