Cache Cookie Session
The operations of these three objects are quite similar, with some minor differences in the API and storage locations.
Cache: Stored in memory, with an optional expiration time (default is 2 hours).
Cookie: Stored in the browser's request header, with an optional expiration time (default is 1 day).
Session: Stores a session key in the cookie, while the session data is stored on the server. The session has a default expiration time of 30 minutes.
The common operations for these objects include:
get, set, remove, containsKey
k.session.set("key", "value");
k.cookie.set("key", "value", 2);
k.cache.set("key", "value", 12000);
var value = k.session.get("key");
var hasValue = k.cache.containsKey("key");
k.cache.remove("key");
Cache supports lazy generation of value
k.cache.getOrCreate("mykey", function () { return "myvalue" }, 12000);