Skip to main content

invalidate_channel

Function invalidate_channel 

Source
pub async fn invalidate_channel(
    guild_id: Id<GuildMarker>,
    channel_id: Id<ChannelMarker>,
)
Expand description

Drops every cached view of channel_id.

Both caches hold permission overwrites, and those decide whether a linked channel may be expanded. Serving them after Discord has changed them means authorizing against permissions that no longer exist — a channel made private would keep being treated as public. Callers invoke this from the gateway events that report such a change.

The whole guild’s channel list goes too, not just the one entry: the list is a single cached value holding every channel’s overwrites, so there is no way to replace one member of it.

The guild’s generation advances before anything is dropped. That, not the dropping, is what keeps data read before this call from being served again, including what a lookup still in flight inserts afterwards.