package sihl-cache
A module that provides services to store and retrieve data with key-value semantics
Install
Dune Dependency
Authors
Maintainers
Sources
0.3.0.tar.gz
md5=3265ccfac470edc97a524259ec98e15b
sha512=0e6b184d5077a444a0583b65e5b99ba69e798321a34bc99bcc121eb82a3555b86ce8d1c7d3fc6afdcadf87d76f2d903702e5e6252b6b06fd7c1311b712298cc9
doc/index.html
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.
Currently MariaDb (Sihl_cache.MariaDb
) and PostgreSql (Sihl_cache.PostgreSql
) are supported.
Installation
Backend
First, choose a backend in service/service.ml
:
module Cache = Sihl_cache.PostgreSql
Registration
Then, register the service in run/run.ml
:
let services = [ Service.Cache.register () ]
Migrations
Run pending migrations with make sihl migrate
.
Usage
The API is documented in Sihl.Contract.Cache.Sig
.
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)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page