Skip to content

Cache

Class responsible for handling the underlying cache for all objects in Discord-Luau.

Entries are evicted explicitly via remove() - callers must call this on DELETE gateway events. The previous weak-table + TTL-coroutine approach was removed because it could silently evict entries while they were still valid, and the coroutine workaround that prevented that eviction made the TTL meaningless.

Cache.store  :: {
{ [K]: V } }
Cache : set ( key value )  -> ()

Stores a value in the cache under the given key.

Parameters

key: K
value: V
Cache : get ( key )  -> V?

Returns the cached value for the given key, or nil if not present.

Parameters

key: K

Returns

V?
Cache : remove ( key )  -> ()

Removes the cached value for the given key. Call this on DELETE gateway events to keep the cache consistent with Discord’s state.

Parameters

key: K
Cache . new ( )  -> Cache<K, V>

Constructor for the Cache class.

Returns

Cache<K, V>