Cache
Cache
Key/value get, set, and delete on a cache Repo (ETS, Valkey, ...).
Values
get
get : String -> Transaction (Maybe String)Read a string value from the active cache Repo.
Examples
case Repo.on "cache" (Cache.get "session") of
Ok (Just token) ->
Server.string 200 [] "text/plain" token
Ok Nothing ->
Server.empty 404 []
Err _ ->
Server.empty 500 []set
set : String -> String -> Transaction ()Write a string value to the active cache Repo.
Examples
Repo.on "cache" (Cache.set "session" token)setWithTtl
setWithTtl : String -> String -> Int -> Transaction ()Write a string value that expires after ttlSeconds (must be positive).
Examples
Repo.on "cache" (Cache.setWithTtl "session" token 3600)incr
incr : String -> Transaction IntAtomically increment an integer counter. Missing keys start at 0 then become 1. Returns the new value.
Examples
Repo.on "cache" (Cache.incr "pageviews")expire
expire : String -> Int -> Transaction ()Set the remaining TTL on an existing key. No-op when the key is missing. ttlSeconds must be positive.
Examples
Repo.on "cache" (Cache.expire "session" 600)delete
delete : String -> Transaction ()Delete a key from the active cache Repo.
Examples
Repo.on "cache" (Cache.delete "session")