Modules
Cache
Fast values that don't have to last: a lobby, a cooldown, a counter, a level that is expensive to build. A restart of the server empties the cache, keep what matters in Player Data.
Tiers
Every key picks a tier:
| Tier | What it is |
|---|---|
| Memory | The default. The fastest, the plan keeps a part of the memory of the server for the account and lends more while there is room |
| Disk | Larger and a little slower, it counts against the cloud saves |
await ansekai.cache.set("lobby", { players: 3 }, { ttl: 60 });
await ansekai.cache.set("level", bigLevel, { tier: "disk", ttl: 3600 });
const lobby = await ansekai.cache.get("lobby");
const placed = await ansekai.cache.setIfAbsent("lock", true, { ttl: 10 });
await ansekai.cache.increment("visits", 1);ansekai.cache.set("lobby", { players = 3 }, { ttl = 60 })
ansekai.cache.set("leader", { name = "Mira" }) -- A key of the whole game
local lobby = ansekai.cache.get("lobby")
ansekai.cache.increment("visits", 1)A value is up to 12 KB, ttl is in seconds and 30 days at most. A full cache drops the oldest keys first, then answers cache_full.
Keys of a player and of the game
A key from a client belongs to its player. A key of the whole game has no player, server code writes it and clients only read it with { shared: true }.
const leader = await ansekai.cache.get("leader", { shared: true });Server code names a player with { player = id } in the options, or as the last argument of get and delete.
Disk limit of a game
The plan gives the account a part of its cloud saves for the cache on disk. The Cache page of a game can keep that game to less of it, a smaller limit drops its oldest keys at once.
Updated November 21, 2026