package sihl-cache
 sectionYPositions = computeSectionYPositions($el), 10)"
  x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
  >
  
  
On This Page
  
  
  Cache service implementations for Sihl
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
  
    
      3.0.1.tar.gz
    
    
        
    
  
  
  
    
  
  
    
  
        md5=4157e84bdd55758a1a2fb1ccb4172663
    
    
  sha512=31aa7fc2b27a2713955b2bd6ed2b727245796e26361d0ba163501a79b9f46a75d258fbc6165eb68ddbfb16b18f96560367946fa91f856c14027fbfb2286233e9
    
    
  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.PostgreSqlRegistration
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.
  
  (* Associated user_id with a value *)
  let%lwt () = Service.Cache.set ("user_id", Some "56") in
  let%lwt 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