Developer guide
The API classes ship inside the plugin jar. Add the jar as a compileOnly dependency and SaunaCache
as a depend in plugin.yml:
dependencies { compileOnly(files("libs/SaunaCache-0.6.0.jar")) }Get the service once, on enable:
val cache = server.servicesManager.load(SaunaCache::class.java) ?: error("SaunaCache is not installed")val ns = cache.namespace("my-plugin")Values
Section titled “Values”ns.set("motd", "Welcome back", ttl = 1.hours)val motd: String? = ns.get("motd")All calls are suspending; outside coroutines use the *Async variants, which return a
CompletableFuture. Never call .join() on the main thread.
ns.withLock("reward:${player.uniqueId}", timeout = 5.seconds) { giveDailyReward(player)}A lock is held for at most timeout, even if the server crashes inside the block.
Sorted sets
Section titled “Sorted sets”val board = ns.sortedSet("kills")board.increment(player.name, 1.0)val top = board.top(10)Sorted sets use the namespace TTL, so a weekly board is just a namespace with ttl: 7d.