Documentation ¶
Index ¶
- func PolicyAll[T any](_ T) bool
- func PolicyDefault[T any](t T) bool
- func PolicyNone[T any](_ T) bool
- type Cache
- type Caches
- type ChannelCache
- type ChannelCacheImpl
- func (c *ChannelCacheImpl) GetDMChannel(channelID snowflake.ID) (discord.DMChannel, bool)
- func (c *ChannelCacheImpl) GetGuildAudioChannel(channelID snowflake.ID) (discord.GuildAudioChannel, bool)
- func (c *ChannelCacheImpl) GetGuildCategoryChannel(channelID snowflake.ID) (discord.GuildCategoryChannel, bool)
- func (c *ChannelCacheImpl) GetGuildChannel(channelID snowflake.ID) (discord.GuildChannel, bool)
- func (c *ChannelCacheImpl) GetGuildMessageChannel(channelID snowflake.ID) (discord.GuildMessageChannel, bool)
- func (c *ChannelCacheImpl) GetGuildNewsChannel(channelID snowflake.ID) (discord.GuildNewsChannel, bool)
- func (c *ChannelCacheImpl) GetGuildNewsThread(channelID snowflake.ID) (discord.GuildThread, bool)
- func (c *ChannelCacheImpl) GetGuildPrivateThread(channelID snowflake.ID) (discord.GuildThread, bool)
- func (c *ChannelCacheImpl) GetGuildPublicThread(channelID snowflake.ID) (discord.GuildThread, bool)
- func (c *ChannelCacheImpl) GetGuildStageVoiceChannel(channelID snowflake.ID) (discord.GuildStageVoiceChannel, bool)
- func (c *ChannelCacheImpl) GetGuildTextChannel(channelID snowflake.ID) (discord.GuildTextChannel, bool)
- func (c *ChannelCacheImpl) GetGuildThread(channelID snowflake.ID) (discord.GuildThread, bool)
- func (c *ChannelCacheImpl) GetGuildVoiceChannel(channelID snowflake.ID) (discord.GuildVoiceChannel, bool)
- func (c *ChannelCacheImpl) GetMessageChannel(channelID snowflake.ID) (discord.MessageChannel, bool)
- func (c *ChannelCacheImpl) GuildChannels(guildID snowflake.ID) []discord.GuildChannel
- func (c *ChannelCacheImpl) GuildThreadsInChannel(channelID snowflake.ID) []discord.GuildThread
- type Config
- type ConfigOpt
- func WithCacheFlags(flags ...Flags) ConfigOpt
- func WithChannelCachePolicy(policy Policy[discord.Channel]) ConfigOpt
- func WithEmojiCachePolicy(policy Policy[discord.Emoji]) ConfigOpt
- func WithGuildCachePolicy(policy Policy[discord.Guild]) ConfigOpt
- func WithGuildScheduledEventCachePolicy(policy Policy[discord.GuildScheduledEvent]) ConfigOpt
- func WithMemberCachePolicy(policy Policy[discord.Member]) ConfigOpt
- func WithMessageCachePolicy(policy Policy[discord.Message]) ConfigOpt
- func WithPresenceCachePolicy(policy Policy[discord.Presence]) ConfigOpt
- func WithRoleCachePolicy(policy Policy[discord.Role]) ConfigOpt
- func WithStageInstanceCachePolicy(policy Policy[discord.StageInstance]) ConfigOpt
- func WithStickerCachePolicy(policy Policy[discord.Sticker]) ConfigOpt
- func WithThreadMemberCachePolicy(policy Policy[discord.ThreadMember]) ConfigOpt
- func WithVoiceStateCachePolicy(policy Policy[discord.VoiceState]) ConfigOpt
- type DefaultCache
- func (c *DefaultCache[T]) All() []T
- func (c *DefaultCache[T]) FindAll(cacheFindFunc FilterFunc[T]) []T
- func (c *DefaultCache[T]) FindFirst(cacheFindFunc FilterFunc[T]) (T, bool)
- func (c *DefaultCache[T]) ForEach(forEachFunc func(entity T))
- func (c *DefaultCache[T]) Get(id snowflake.ID) (T, bool)
- func (c *DefaultCache[T]) MapAll() map[snowflake.ID]T
- func (c *DefaultCache[T]) Put(id snowflake.ID, entity T)
- func (c *DefaultCache[T]) Remove(id snowflake.ID) (T, bool)
- func (c *DefaultCache[T]) RemoveIf(filterFunc FilterFunc[T])
- type DefaultGroupedCache
- func (c *DefaultGroupedCache[T]) All() map[snowflake.ID][]T
- func (c *DefaultGroupedCache[T]) FindAll(cacheFindFunc GroupedCacheFilterFunc[T]) []T
- func (c *DefaultGroupedCache[T]) FindFirst(cacheFindFunc GroupedCacheFilterFunc[T]) (T, bool)
- func (c *DefaultGroupedCache[T]) ForEach(forEachFunc func(groupID snowflake.ID, entity T))
- func (c *DefaultGroupedCache[T]) ForEachGroup(groupID snowflake.ID, forEachFunc func(entity T))
- func (c *DefaultGroupedCache[T]) Get(groupID snowflake.ID, id snowflake.ID) (T, bool)
- func (c *DefaultGroupedCache[T]) GroupAll(groupID snowflake.ID) []T
- func (c *DefaultGroupedCache[T]) GroupFindAll(groupID snowflake.ID, cacheFindFunc GroupedCacheFilterFunc[T]) []T
- func (c *DefaultGroupedCache[T]) GroupFindFirst(groupID snowflake.ID, cacheFindFunc GroupedCacheFilterFunc[T]) (T, bool)
- func (c *DefaultGroupedCache[T]) MapAll() map[snowflake.ID]map[snowflake.ID]T
- func (c *DefaultGroupedCache[T]) MapGroupAll(groupID snowflake.ID) map[snowflake.ID]T
- func (c *DefaultGroupedCache[T]) Put(groupID snowflake.ID, id snowflake.ID, entity T)
- func (c *DefaultGroupedCache[T]) Remove(groupID snowflake.ID, id snowflake.ID) (entity T, ok bool)
- func (c *DefaultGroupedCache[T]) RemoveAll(groupID snowflake.ID)
- func (c *DefaultGroupedCache[T]) RemoveIf(filterFunc GroupedCacheFilterFunc[T])
- type FilterFunc
- type Flags
- type GroupedCache
- type GroupedCacheFilterFunc
- type GuildCache
- type GuildCacheImpl
- func (c *GuildCacheImpl) IsUnavailable(guildID snowflake.ID) bool
- func (c *GuildCacheImpl) IsUnready(shardID int, guildID snowflake.ID) bool
- func (c *GuildCacheImpl) SetAvailable(guildID snowflake.ID)
- func (c *GuildCacheImpl) SetReady(shardID int, guildID snowflake.ID)
- func (c *GuildCacheImpl) SetUnavailable(id snowflake.ID)
- func (c *GuildCacheImpl) SetUnready(shardID int, guildID snowflake.ID)
- func (c *GuildCacheImpl) UnavailableGuilds() []snowflake.ID
- func (c *GuildCacheImpl) UnreadyGuilds(shardID int) []snowflake.ID
- type Policy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PolicyDefault ¶ added in v0.10.3
func PolicyNone ¶ added in v0.10.3
Types ¶
type Cache ¶
type Cache[T any] interface { Get(id snowflake.ID) (T, bool) Put(id snowflake.ID, entity T) Remove(id snowflake.ID) (T, bool) RemoveIf(filterFunc FilterFunc[T]) All() []T MapAll() map[snowflake.ID]T FindFirst(cacheFindFunc FilterFunc[T]) (T, bool) FindAll(cacheFindFunc FilterFunc[T]) []T ForEach(func(entity T)) }
type Caches ¶
type Caches interface { CacheFlags() Flags GetMemberPermissions(guildID snowflake.ID, member discord.Member) discord.Permissions GetMemberPermissionsInChannel(channel discord.GuildChannel, member discord.Member) discord.Permissions MemberRoles(member discord.Member) []discord.Role AudioChannelMembers(channel discord.GuildAudioChannel) []discord.Member GetSelfUser() (discord.OAuth2User, bool) PutSelfUser(user discord.OAuth2User) GetSelfMember(guildID snowflake.ID) (discord.Member, bool) Roles() GroupedCache[discord.Role] Members() GroupedCache[discord.Member] ThreadMembers() GroupedCache[discord.ThreadMember] Presences() GroupedCache[discord.Presence] VoiceStates() GroupedCache[discord.VoiceState] Messages() GroupedCache[discord.Message] Emojis() GroupedCache[discord.Emoji] Stickers() GroupedCache[discord.Sticker] Guilds() GuildCache Channels() ChannelCache StageInstances() GroupedCache[discord.StageInstance] GuildScheduledEvents() GroupedCache[discord.GuildScheduledEvent] }
type ChannelCache ¶
type ChannelCache interface { Cache[discord.Channel] GuildChannels(guildID snowflake.ID) []discord.GuildChannel GuildThreadsInChannel(channelID snowflake.ID) []discord.GuildThread GetGuildChannel(channelID snowflake.ID) (discord.GuildChannel, bool) GetMessageChannel(channelID snowflake.ID) (discord.MessageChannel, bool) GetGuildMessageChannel(channelID snowflake.ID) (discord.GuildMessageChannel, bool) GetGuildThread(channelID snowflake.ID) (discord.GuildThread, bool) GetGuildAudioChannel(channelID snowflake.ID) (discord.GuildAudioChannel, bool) GetGuildTextChannel(channelID snowflake.ID) (discord.GuildTextChannel, bool) GetDMChannel(channelID snowflake.ID) (discord.DMChannel, bool) GetGuildVoiceChannel(channelID snowflake.ID) (discord.GuildVoiceChannel, bool) GetGuildCategoryChannel(channelID snowflake.ID) (discord.GuildCategoryChannel, bool) GetGuildNewsChannel(channelID snowflake.ID) (discord.GuildNewsChannel, bool) GetGuildNewsThread(channelID snowflake.ID) (discord.GuildThread, bool) GetGuildPublicThread(channelID snowflake.ID) (discord.GuildThread, bool) GetGuildPrivateThread(channelID snowflake.ID) (discord.GuildThread, bool) GetGuildStageVoiceChannel(channelID snowflake.ID) (discord.GuildStageVoiceChannel, bool) }
func NewChannelCache ¶
type ChannelCacheImpl ¶
func (*ChannelCacheImpl) GetDMChannel ¶
func (c *ChannelCacheImpl) GetDMChannel(channelID snowflake.ID) (discord.DMChannel, bool)
func (*ChannelCacheImpl) GetGuildAudioChannel ¶
func (c *ChannelCacheImpl) GetGuildAudioChannel(channelID snowflake.ID) (discord.GuildAudioChannel, bool)
func (*ChannelCacheImpl) GetGuildCategoryChannel ¶
func (c *ChannelCacheImpl) GetGuildCategoryChannel(channelID snowflake.ID) (discord.GuildCategoryChannel, bool)
func (*ChannelCacheImpl) GetGuildChannel ¶
func (c *ChannelCacheImpl) GetGuildChannel(channelID snowflake.ID) (discord.GuildChannel, bool)
func (*ChannelCacheImpl) GetGuildMessageChannel ¶
func (c *ChannelCacheImpl) GetGuildMessageChannel(channelID snowflake.ID) (discord.GuildMessageChannel, bool)
func (*ChannelCacheImpl) GetGuildNewsChannel ¶
func (c *ChannelCacheImpl) GetGuildNewsChannel(channelID snowflake.ID) (discord.GuildNewsChannel, bool)
func (*ChannelCacheImpl) GetGuildNewsThread ¶
func (c *ChannelCacheImpl) GetGuildNewsThread(channelID snowflake.ID) (discord.GuildThread, bool)
func (*ChannelCacheImpl) GetGuildPrivateThread ¶
func (c *ChannelCacheImpl) GetGuildPrivateThread(channelID snowflake.ID) (discord.GuildThread, bool)
func (*ChannelCacheImpl) GetGuildPublicThread ¶
func (c *ChannelCacheImpl) GetGuildPublicThread(channelID snowflake.ID) (discord.GuildThread, bool)
func (*ChannelCacheImpl) GetGuildStageVoiceChannel ¶
func (c *ChannelCacheImpl) GetGuildStageVoiceChannel(channelID snowflake.ID) (discord.GuildStageVoiceChannel, bool)
func (*ChannelCacheImpl) GetGuildTextChannel ¶
func (c *ChannelCacheImpl) GetGuildTextChannel(channelID snowflake.ID) (discord.GuildTextChannel, bool)
func (*ChannelCacheImpl) GetGuildThread ¶
func (c *ChannelCacheImpl) GetGuildThread(channelID snowflake.ID) (discord.GuildThread, bool)
func (*ChannelCacheImpl) GetGuildVoiceChannel ¶
func (c *ChannelCacheImpl) GetGuildVoiceChannel(channelID snowflake.ID) (discord.GuildVoiceChannel, bool)
func (*ChannelCacheImpl) GetMessageChannel ¶
func (c *ChannelCacheImpl) GetMessageChannel(channelID snowflake.ID) (discord.MessageChannel, bool)
func (*ChannelCacheImpl) GuildChannels ¶
func (c *ChannelCacheImpl) GuildChannels(guildID snowflake.ID) []discord.GuildChannel
func (*ChannelCacheImpl) GuildThreadsInChannel ¶
func (c *ChannelCacheImpl) GuildThreadsInChannel(channelID snowflake.ID) []discord.GuildThread
type Config ¶
type Config struct { CacheFlags Flags GuildCachePolicy Policy[discord.Guild] ChannelCachePolicy Policy[discord.Channel] StageInstanceCachePolicy Policy[discord.StageInstance] GuildScheduledEventCachePolicy Policy[discord.GuildScheduledEvent] RoleCachePolicy Policy[discord.Role] MemberCachePolicy Policy[discord.Member] ThreadMemberCachePolicy Policy[discord.ThreadMember] PresenceCachePolicy Policy[discord.Presence] VoiceStateCachePolicy Policy[discord.VoiceState] MessageCachePolicy Policy[discord.Message] EmojiCachePolicy Policy[discord.Emoji] StickerCachePolicy Policy[discord.Sticker] }
func DefaultConfig ¶
func DefaultConfig() *Config
type ConfigOpt ¶
type ConfigOpt func(config *Config)
func WithCacheFlags ¶
func WithChannelCachePolicy ¶ added in v0.10.3
func WithEmojiCachePolicy ¶ added in v0.10.3
func WithGuildCachePolicy ¶ added in v0.10.3
func WithGuildScheduledEventCachePolicy ¶ added in v0.10.3
func WithGuildScheduledEventCachePolicy(policy Policy[discord.GuildScheduledEvent]) ConfigOpt
func WithPresenceCachePolicy ¶ added in v0.10.3
func WithRoleCachePolicy ¶ added in v0.10.3
func WithStageInstanceCachePolicy ¶ added in v0.10.3
func WithStageInstanceCachePolicy(policy Policy[discord.StageInstance]) ConfigOpt
func WithStickerCachePolicy ¶ added in v0.10.3
func WithThreadMemberCachePolicy ¶ added in v0.10.3
func WithThreadMemberCachePolicy(policy Policy[discord.ThreadMember]) ConfigOpt
func WithVoiceStateCachePolicy ¶ added in v0.10.3
func WithVoiceStateCachePolicy(policy Policy[discord.VoiceState]) ConfigOpt
type DefaultCache ¶
type DefaultCache[T any] struct { // contains filtered or unexported fields }
func (*DefaultCache[T]) All ¶
func (c *DefaultCache[T]) All() []T
func (*DefaultCache[T]) FindAll ¶
func (c *DefaultCache[T]) FindAll(cacheFindFunc FilterFunc[T]) []T
func (*DefaultCache[T]) FindFirst ¶
func (c *DefaultCache[T]) FindFirst(cacheFindFunc FilterFunc[T]) (T, bool)
func (*DefaultCache[T]) ForEach ¶
func (c *DefaultCache[T]) ForEach(forEachFunc func(entity T))
func (*DefaultCache[T]) Get ¶
func (c *DefaultCache[T]) Get(id snowflake.ID) (T, bool)
func (*DefaultCache[T]) MapAll ¶
func (c *DefaultCache[T]) MapAll() map[snowflake.ID]T
func (*DefaultCache[T]) Put ¶
func (c *DefaultCache[T]) Put(id snowflake.ID, entity T)
func (*DefaultCache[T]) Remove ¶
func (c *DefaultCache[T]) Remove(id snowflake.ID) (T, bool)
func (*DefaultCache[T]) RemoveIf ¶
func (c *DefaultCache[T]) RemoveIf(filterFunc FilterFunc[T])
type DefaultGroupedCache ¶
type DefaultGroupedCache[T any] struct { // contains filtered or unexported fields }
func (*DefaultGroupedCache[T]) All ¶
func (c *DefaultGroupedCache[T]) All() map[snowflake.ID][]T
func (*DefaultGroupedCache[T]) FindAll ¶
func (c *DefaultGroupedCache[T]) FindAll(cacheFindFunc GroupedCacheFilterFunc[T]) []T
func (*DefaultGroupedCache[T]) FindFirst ¶
func (c *DefaultGroupedCache[T]) FindFirst(cacheFindFunc GroupedCacheFilterFunc[T]) (T, bool)
func (*DefaultGroupedCache[T]) ForEach ¶
func (c *DefaultGroupedCache[T]) ForEach(forEachFunc func(groupID snowflake.ID, entity T))
func (*DefaultGroupedCache[T]) ForEachGroup ¶
func (c *DefaultGroupedCache[T]) ForEachGroup(groupID snowflake.ID, forEachFunc func(entity T))
func (*DefaultGroupedCache[T]) Get ¶
func (c *DefaultGroupedCache[T]) Get(groupID snowflake.ID, id snowflake.ID) (T, bool)
func (*DefaultGroupedCache[T]) GroupAll ¶
func (c *DefaultGroupedCache[T]) GroupAll(groupID snowflake.ID) []T
func (*DefaultGroupedCache[T]) GroupFindAll ¶
func (c *DefaultGroupedCache[T]) GroupFindAll(groupID snowflake.ID, cacheFindFunc GroupedCacheFilterFunc[T]) []T
func (*DefaultGroupedCache[T]) GroupFindFirst ¶
func (c *DefaultGroupedCache[T]) GroupFindFirst(groupID snowflake.ID, cacheFindFunc GroupedCacheFilterFunc[T]) (T, bool)
func (*DefaultGroupedCache[T]) MapAll ¶
func (c *DefaultGroupedCache[T]) MapAll() map[snowflake.ID]map[snowflake.ID]T
func (*DefaultGroupedCache[T]) MapGroupAll ¶
func (c *DefaultGroupedCache[T]) MapGroupAll(groupID snowflake.ID) map[snowflake.ID]T
func (*DefaultGroupedCache[T]) Put ¶
func (c *DefaultGroupedCache[T]) Put(groupID snowflake.ID, id snowflake.ID, entity T)
func (*DefaultGroupedCache[T]) Remove ¶
func (c *DefaultGroupedCache[T]) Remove(groupID snowflake.ID, id snowflake.ID) (entity T, ok bool)
func (*DefaultGroupedCache[T]) RemoveAll ¶
func (c *DefaultGroupedCache[T]) RemoveAll(groupID snowflake.ID)
func (*DefaultGroupedCache[T]) RemoveIf ¶
func (c *DefaultGroupedCache[T]) RemoveIf(filterFunc GroupedCacheFilterFunc[T])
type FilterFunc ¶
type Flags ¶
type Flags int
Flags are used to enable/disable certain internal caches
const ( FlagGuilds Flags = 1 << iota FlagGuildScheduledEvents FlagMembers FlagThreadMembers FlagMessages FlagPresences FlagChannels FlagRoles FlagEmojis FlagStickers FlagVoiceStates FlagStageInstances FlagsNone Flags = 0 FlagsDefault = FlagsNone FlagsAll = FlagGuilds | FlagGuildScheduledEvents | FlagChannels | FlagRoles | FlagEmojis | FlagStickers | FlagVoiceStates | FlagStageInstances | FlagPresences )
values for CacheFlags
type GroupedCache ¶
type GroupedCache[T any] interface { Get(groupID snowflake.ID, id snowflake.ID) (T, bool) Put(groupID snowflake.ID, id snowflake.ID, entity T) Remove(groupID snowflake.ID, id snowflake.ID) (T, bool) RemoveAll(groupID snowflake.ID) RemoveIf(filterFunc GroupedCacheFilterFunc[T]) All() map[snowflake.ID][]T GroupAll(groupID snowflake.ID) []T MapAll() map[snowflake.ID]map[snowflake.ID]T MapGroupAll(groupID snowflake.ID) map[snowflake.ID]T FindFirst(cacheFindFunc GroupedCacheFilterFunc[T]) (T, bool) GroupFindFirst(groupID snowflake.ID, cacheFindFunc GroupedCacheFilterFunc[T]) (T, bool) FindAll(cacheFindFunc GroupedCacheFilterFunc[T]) []T GroupFindAll(groupID snowflake.ID, cacheFindFunc GroupedCacheFilterFunc[T]) []T ForEach(func(groupID snowflake.ID, entity T)) ForEachGroup(groupID snowflake.ID, forEachFunc func(entity T)) }
func NewGroupedCache ¶
func NewGroupedCache[T any](flags Flags, neededFlags Flags, policy Policy[T]) GroupedCache[T]
type GroupedCacheFilterFunc ¶
type GuildCache ¶
type GuildCache interface { Cache[discord.Guild] SetReady(shardID int, guildID snowflake.ID) SetUnready(shardID int, guildID snowflake.ID) IsUnready(shardID int, guildID snowflake.ID) bool UnreadyGuilds(shardID int) []snowflake.ID SetAvailable(guildID snowflake.ID) }
func NewGuildCache ¶
type GuildCacheImpl ¶
func (*GuildCacheImpl) IsUnavailable ¶
func (c *GuildCacheImpl) IsUnavailable(guildID snowflake.ID) bool
func (*GuildCacheImpl) IsUnready ¶
func (c *GuildCacheImpl) IsUnready(shardID int, guildID snowflake.ID) bool
func (*GuildCacheImpl) SetAvailable ¶
func (c *GuildCacheImpl) SetAvailable(guildID snowflake.ID)
func (*GuildCacheImpl) SetReady ¶
func (c *GuildCacheImpl) SetReady(shardID int, guildID snowflake.ID)
func (*GuildCacheImpl) SetUnavailable ¶
func (c *GuildCacheImpl) SetUnavailable(id snowflake.ID)
func (*GuildCacheImpl) SetUnready ¶
func (c *GuildCacheImpl) SetUnready(shardID int, guildID snowflake.ID)
func (*GuildCacheImpl) UnavailableGuilds ¶
func (c *GuildCacheImpl) UnavailableGuilds() []snowflake.ID
func (*GuildCacheImpl) UnreadyGuilds ¶
func (c *GuildCacheImpl) UnreadyGuilds(shardID int) []snowflake.ID
type Policy ¶
Policy can be used to define your own policy for when entities should be cached.
func AllPolicies ¶
AllPolicies is a shorthand for CachePolicy.And(CachePolicy).And(CachePolicy) etc.
Click to show internal directories.
Click to hide internal directories.