Skip to main content

npm

Source

See the Plugins guide for how plugins from wolfstar-project/plugins fit alongside the core framework.

Description

@wolfstar/plugin-cache is the cache behind the managers of @wolfstar/plugin-gateway. A Cache is one Map-like EntityCache per Discord entity kind (guilds, users, channels, messages, members, roles, and more). It stores raw, JSON-serializable API data only. Building structures on top of it is the managers’ job, which lets the same data live in a Map or in Redis. Swapping the store never changes the call sites:

Usage

Most of the time you hand the cache to a GatewayClient, which writes every dispatch into it:
You can also use it on its own with any gateway dispatch source:
applyGatewayDispatch also handles cascades. A CHANNEL_DELETE drops that channel’s messages and a GUILD_DELETE drops every entity of that guild. Reactions and poll votes update the cached message. Pass the bot’s user ID as clientUserId so the me flags are right.

Stars module

On framework 6.1 and later, list the ./module entry in modules in stars.config to add the package to the auto imports. It needs the optional @wolfstar/kit peer dependency, at ^0.2.0 || ^0.3.0.
The module registers no plugin and takes no options. It reserves the cache key of stars.config for future options, so no other module can claim it. @wolfstar/plugin-gateway still constructs the cache.

Redis

createRedisCache takes any client that exposes the commands it needs, which an ioredis Redis or Cluster instance does as is:
Compressed values are tagged, so turning compression on or off never breaks reading existing values. version downloads license