ExpiringCache

class ExpiringCache<K, V>(val expireIn: Int = 10, val cleanup: Int = 10)

ExpiringCache is a simple cache implementation that stores key-value pairs with an expiration time. It automatically removes expired entries and can be used to cache data that is only valid for a certain period.

Example:

val cache = ExpiringCache<String, String>(plugin, 60) // 60 seconds expiry time

cache.put("key", "value")

val value = cache.get("key") // Returns "value" if within expiry time

cache.remove("key") // Removes the entry

cache.stop() // Stops the cleanup task

Constructors

Link copied to clipboard
constructor(expireIn: Int = 10, cleanup: Int = 10)

Properties

Link copied to clipboard
val cleanup: Int = 10
Link copied to clipboard
val expireIn: Int = 10

Functions

Link copied to clipboard
fun get(key: K): V?
Link copied to clipboard
fun put(key: K, value: V)
Link copied to clipboard
Link copied to clipboard
fun stop()