@antiraid-ext/cache
API reference for @antiraid-ext/cache
@antiraid-ext/cache
Types
CachedTable
A CachedTable is a table that stores key-value pairs with an expiration time.
Raw Type
--- A CachedTable is a table that stores key-value pairs with an expiration time.
type CachedTable<K, V> = {
--- Gets a value from the cache by its key.
--- @field {[K]: V} The table that stores the key-value pairs
get: (self: CachedTable<K, V>, key: K) -> V?,
--- Sets a value in the cache with an expiration time.
--- @param key The key to set the value for
--- @param value The value to set
--- @param expiry The time in seconds after which the value will expire
--- @return nil
set: (self: CachedTable<K, V>, key: K, value: V, expiry: number) -> (),
--- Removes a value from the cache by its key.
--- @param key The key to remove
--- @return nil
remove: (self: CachedTable<K, V>, key: K) -> (),
--- Closes the cache, removing all key-value pairs and cancelling any pending expiries.
--- @return nil
close: (self: CachedTable<K, V>) -> (),
--- Gets the number of key-value pairs in the cache.
--- @return number The number of key-value pairs in the cache
len: (self: CachedTable<K, V>) -> number
}
Prop | Type | Description |
---|---|---|
get | Gets a value from the cache by its key. | |
set | Sets a value in the cache with an expiration time. | |
remove | Removes a value from the cache by its key. | |
close | (self) -> () | Closes the cache, removing all key-value pairs and cancelling any pending expiries. |
len | (self) -> number | Gets the number of key-value pairs in the cache. |
Functions
CachedTable.new
Function Signature
function CachedTable.new<K, V>() -> CachedTable<K, V> end
Generics
K
This generic is unconstrained and can be any type
V
This generic is unconstrained and can be any type
Returns
ret1
CachedTable<K, V>
CachedTable
Function Signature
function CachedTable<K, V>(key: K) -> V? end
Generics
K
This generic is unconstrained and can be any type
V
This generic is unconstrained and can be any type
Arguments
key
Returns
ret1
V?
CachedTable
Function Signature
function CachedTable<K, V>(key: K, value: V, expiry: number) end
Generics
K
This generic is unconstrained and can be any type
V
This generic is unconstrained and can be any type
Arguments
key
value
expiry
CachedTable
Function Signature
function CachedTable<K, V>(key: K) end
Generics
K
This generic is unconstrained and can be any type
V
This generic is unconstrained and can be any type
Arguments
key
CachedTable
Function Signature
function CachedTable<K, V>() end
Generics
K
This generic is unconstrained and can be any type
V
This generic is unconstrained and can be any type
CachedTable
Function Signature
function CachedTable<K, V>() -> number end
Generics
K
This generic is unconstrained and can be any type
V
This generic is unconstrained and can be any type
Returns
ret1
Last updated on