Skip to content

Cache

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

Properties

store

Cache.store  :: {
      {… [K]: V …}    }

expiry

Cache.expiry  :: number

Methods

The Cache instance has no set methods!

Functions

set

Cache . set (

     self: Cache<K, V>
     key: K
     value: V
)  -> ()

Responsible for storing something in cache, will then store both the key and value so that these objects don’t get cleaned up by the luau gc.

get

Cache . get (

     self: Cache<K, V>
     key: K
)  -> ()

Responsible for getting something in the cache, will either return V or nil

new

Cache . new (

     expiry: number
)  -> ()

Constructor for the Cache class.