package savvy
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
A straightforward OAuth2 client
Install
dune-project
Dependency
Authors
Maintainers
Sources
savvy-0.4.1.tbz
sha256=d6ef1f13c522e1d920e2ddc707ee7da4392bf178d8ccbaaea50cc5a2b67c10ad
sha512=74ee303d5b80453ce8a6c6fb49e765b91079bf0b4ed84801ad7d9adcc1dd4ebb22075706e9de4ee90800e2bef5f2eb133ea94f6d82c4e216159ea0e298bb88e8
doc/src/savvy.storage/storage.ml.html
Source file storage.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(* Any user-defined storage implementation must have at least these three methods *) module type STORAGE_UNIT = sig type t type value (* (string * config * float) *) (* All storage mechanisms want to be sure that old data is cleared out eventually *) val ttl: float (* When implementing this interface, I recommend doing a clean out of stale values in get *) val get: string -> (value * float) option val remove: string -> unit val update: string -> value -> unit end module type STORAGE_KIND = sig type value val ttl : float end module MakeInMemoryStorage(V : STORAGE_KIND) : STORAGE_UNIT with type value = V.value = struct type value = V.value type stored = (value * float) type t = (string, stored) Hashtbl.t let ttl = V.ttl let store = Hashtbl.create 100 let is_expired (_value, created_at) = Unix.time () -. created_at > V.ttl let clean () = Hashtbl.filter_map_inplace (fun _key v -> if is_expired v then None else Some v) store (* Due to sealing, only the below methods are publicly accessible *) let get state = clean (); Hashtbl.find_opt store state let remove state = Hashtbl.remove store state let update state value = Hashtbl.replace store state (value, Unix.time ()) end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>