val kind = Option.valOf (Web.Conn.formvar "kind") handle _ => "Size" val cache = let val (k,name) = case kind of "WhileUsed" => (Web.Cache.WhileUsed (SOME(Time.fromSeconds 20),SOME(10000)),"users1") | "TimeOut" => (Web.Cache.TimeOut (SOME(Time.fromSeconds 20), SOME(10000)),"users2") | "Size" => (Web.Cache.WhileUsed (NONE, SOME(10000)),"users3") in Web.Cache.get (Web.Cache.String, Web.Cache.Pair Web.Cache.Int Web.Cache.String, name, k) end fun pp_kind kind = case kind of "Size" => `^kind of size 10000` | _ => `^kind. Entries live in the cache in approximately 20 seconds.
` fun returnPage s = Page.return "Caching Demonstration" (`^s
Using cache kind: ` ^^ (pp_kind kind) ^^ `
Go back to Cache Demo Home Page.`) val _ = (* new_p is true if new value added *) case Web.Conn.formvar "email" of NONE => Web.returnRedirect "cache.sml" | SOME email => returnPage (case Web.Cache.lookup cache email of SOME(uid,name) => "Name and userid for " ^ email ^ " is: (" ^ name ^ "," ^ (Int.toString uid) ^ ")" | NONE => "No name in cache for " ^ email)