Cache This page describes one aspect of bot configuration. For more information on how to create and set up a bot, see the relevant documentation .
The cache
builder allows you to change Kord's caching settings . Kord Extensions provides some additional default settings over Kord's own:
Configures a lruCache
for caching up to 10,000 recent messages
Changes the default caching strategy to cacheWithCachingRestFallback
, which means that Kord will cache all entities that are retrieved via REST calls in addition to hose provided by the gateway.
It's possible that using this strategy may give you incomplete data when dealing with types of data that aren't fully cached automatically. For example, if a member is banned from a guild, and you don't yet have all the guild's bans in the cache, Kord will only keep track of bans that the bot has seen happen. If this is a problem for you, then you have a few options:
Fill the cache yourself. For example, for guild members, you could configure the members
builder to request all guild members from the gateway, and set up the required intents.
Change the default strategy to cacheWithRestFallback
, which won't cache anything retrieved via REST calls.
Temporarily use another supply strategy when retrieving these types of data. For example, you could use something like guild.withStrategy(EntitySupplyStrategy.cachingRest).bans
.
Use one of the equivalent fetch
functions to skip the cache entirely.
For most purposes, the first approach will likely be the most sensible — but the correct approach will heavily depend on your bot and how you need the cache to function.
ExtensibleBot(TOKEN) {
// ...
cache {
cachedMessages = 10_000
defaultStrategy = EntitySupplyStrategy.cacheWithCachingRestFallback
}
}
Builders Builder
Receiver
Parameters
Description
kord
KordCacheBuilder
ClientResources
Register a callback that will be used to directly configure Kord's cache.
transformCache
Kord
DataCache
Register a callback that will be used to directly modify Kord's data cache settings.
Last modified: 20 November 2024