Andreas Garnæs

How to test Async OCaml code

In the previous blog post, we used Core and Async to write a tiny library for talking to Memcached using the binary protocol. I wanted to write tests for the library in a readable and succint manner to ensure correctness – the type system cannot ensure binary data is parsed correctly after all. The regular go-to tool for testing OCaml code is OUnit, but this doesn’t work well with Async. As I couldn’t find a suitable library, I decided to write something myself.

Improved OCaml Memcached client with Core and Async

In the previous blog post, we implemented a simple OCaml library for talking to Memcached with the binary protocol using bitstring. The code uses the baked-in standard library and synchronous IO (blocking), so a lot of time will be wasted waiting for IO. The standard library replacement Core offers cooperative threading with callbacks through Async, similar to Javascript, EventMachine for Ruby or many others. In this blog post we’ll try to rewrite the code from the previous post to use asynchronous IO with Async.

Implementing the Binary Memcached Protocol with OCaml and Bitstring

I’ve known OCaml for a while, but I never really put it to use outside of academic work back in university. After reading Real World Ocaml my excitement for Ocaml reappeared and I wanted to try out Core and Async. At the back of my mind, I also remembered bitstring, an awesome Ocaml library for creating and pattern matching on bitstrings. To cover all three, I decided to write a Memcached client using the binary protocol.