package sihl
The modular functional web framework
Install
Dune Dependency
Authors
Maintainers
Sources
sihl-0.1.2.tbz
sha256=69705a3a35f204acfdda62f61056e3f0ec3ef5bcd1df1508be65b066a0b1df9c
sha512=1987d211f56d0261eefbae978065a4e6781d60ad94b08597875307e5cf6e5a1b79787d9c79f784f5a9f77c35203cfd0b488841a07adfd87b0710d6fd65422b94
doc/src/sihl.session/session_core.ml.html
Source file session_core.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
open Base exception Exception of string type data = (string, string, String.comparator_witness) Map.t type t = { key : string; data : data; expire_date : Ptime.t } (* TODO [jerben] Consider moving date stuff into Utils.Time *) let one_week = 60 * 60 * 24 * 7 let default_expiration_date now = one_week |> Ptime.Span.of_int_s |> Ptime.add_span now let key session = session.key let data session = session.data let is_expired now session = Ptime.is_later now ~than:session.expire_date type data_map = (string * string) list [@@deriving yojson] let string_of_data data = data |> Map.to_alist |> data_map_to_yojson |> Yojson.Safe.to_string let data_of_string str = str |> Yojson.Safe.from_string |> data_map_of_yojson |> Result.map ~f:(Map.of_alist_exn (module String)) type map = (string * string) list [@@deriving yojson] let get key session = Map.find session.data key let set ~key ~value session = { session with data = Map.set ~key ~data:value session.data } let remove ~key session = { session with data = Map.remove session.data key } let pp ppf { key; data; _ } = Caml.Format.fprintf ppf "key: %s data: %s " key (string_of_data data) let t = let encode m = let data = m.data |> string_of_data in Ok (m.key, data, m.expire_date) in let decode (key, data, expire_date) = match data |> data_of_string with | Ok data -> Ok { key; data; expire_date } | Error msg -> Error msg in Caqti_type.(custom ~encode ~decode (tup3 string string ptime))
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>