#Questions about Caching

1 messages · Page 1 of 1 (latest)

stark trout
#

When do things get cached and how long?
How do I know if I can use the get functions instead of the fetch functions?
Is get considerably faster or why should I even use it?

fickle acorn
#

get uses cached information inside the bot and fetch makes an API call so the speed depends on the resources of discord and you connection, not your hardware.

#

And about how long things are cached : It depends.
If the bot is on a server for example the class corresponding to it won't disappear as long as it's on it.
But if you're talking about thing that were fetched I don't think they disappear as long as you don't manually clear the cache.

#

It's hard to say without knowing the framework by heart or by examining its structure.

#

I think the opinion of one of the contributors here would be welcome

stark trout
fickle acorn
#

I don't think so

chilly plaza
#

And for some stuff, object returned by get has more data than that of fetch

#

Eg fetching a guild wouldn't give you the members. Only the in cache one would

stark trout
chilly plaza
#

Objects are put into cache whenever discord sends them over the gateway. Guilds, roles and members are sent on startup, messages on message. And updates on the relevant update events. Roles and members are also updated if they are mentioned in the message iirc

stark trout
stark trout