Cache
This page explains how to work with the internal Cache API.
Cache API
Caches are an extended version of Discord’s Collections. They can be generated with the following snippet:
this.heart.core.discord.core.cache.manager.register(new this.heart.core.discord.core.cache.interface(this.heart, '<cache_name>'));Like any other component of the API, you can fetch and access caches used by Athena.
const cache = this.heart.core.discord.core.cache.manager.get('<cache_name>');Functions
cache.getName(): Returns the name of the cache.cache.setPluginName(name): Sets the name of the plugin associated with this cache.cache.getPluginName(): Returns the name of the plugin associated with this cache.cache.getPlugin(): Returns the plugin instance associated with this cache.cache.set(key, value): Stores a new entry in the cache under the given key.cache.get(key): Retrieves the value stored under the given key. Returnsnullif the key does not exist.cache.has(key): Returnstrueif the given key exists in the cache.cache.delete(key): Removes the entry with the given key.cache.deleteAfter(key): Marks the given key for deletion after a short delay.
To access the raw Discord Collection instance used by the cache, use
cache.cache.
Last updated