LogoAntiRaid

@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
}
PropTypeDescription
get
(self, key: K) -> V?
Gets a value from the cache by its key.
set
(self, key: K, value: V, expiry: number) -> ()
Sets a value in the cache with an expiration time.
remove
(self, key: K) -> ()
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

K

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

K

value

V

expiry

number

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

K

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

number

Last updated on