Legend:
Library
Module
Module type
Parameter
Class
Class type
Sihl Cache
This module provides the cache service and helpers to store arbitrary values. Think of the cache service as a generic key-value store where you can choose a backend.
let open Lwt.Syntax in
(* Associated user_id with a value *)
let* () = Service.Cache.set ("user_id", Some "56") in
let* user_id = Service.Cache.find "user_id" in
let () =
match user_id with
| Some user_id -> print_endline @@ "Found user " ^ user_id
| None -> print_endline "No user found"
(* Delete user_id *)
Service.Cache.set ("user_id", None)