Expand description
A cache containing data received from Shard
s.
Using the cache allows to avoid REST API requests via the http
module where possible.
Issuing too many requests will lead to ratelimits.
§Use by Models
Most models of Discord objects, such as the Message
, GuildChannel
, or Emoji
, have
methods for interacting with that single instance. This feature is only compiled if the model
feature is enabled. An example of this is Guild::edit
, which performs a check to ensure that
the current user has the Manage Guild permission prior to actually performing the HTTP
request. The cache is involved due to the function’s use of unlocking the cache and retrieving
the permissions of the current user. This is an inexpensive method of being able to access data
required by these sugary methods.
§Do I need the Cache?
If you’re asking this, the answer is likely “definitely yes” or “definitely no”; any in-between tends to be “yes”. If you are low on RAM, and need to run on only a couple MB, then the answer is “definitely no”. If you do not care about RAM and want your bot to be able to access data while needing to hit the REST API as little as possible, then the answer is “yes”.
Structs§
Traits§
- Cache
Update - Trait used for updating the cache with a type.