npm
Source
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 aGatewayClient, which writes every dispatch into it:
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.
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.