cache

package
v0.0.0-...-0dc11ae Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PolicyAll

func PolicyAll[T any](_ T) bool

PolicyAll returns a policy that will cache all entities.

func PolicyMembersPending

func PolicyMembersPending(member discord.Member) bool

PolicyMembersPending is a policy that will only cache members that are pending.

func PolicyNone

func PolicyNone[T any](_ T) bool

PolicyNone returns a policy that will never cache anything.

Types

type Cache

type Cache[T any] interface {
	// Get returns a copy of the entity with the given snowflake and a bool whether it was found or not.
	Get(id snowflake.ID) (T, bool)

	// Put stores the given entity with the given snowflake as key. If the entity is already present, it will be overwritten.
	Put(id snowflake.ID, entity T)

	// Remove removes the entity with the given snowflake as key and returns a copy of the entity and a bool whether it was removed or not.
	Remove(id snowflake.ID) (T, bool)

	// RemoveIf removes all entities that pass the given FilterFunc
	RemoveIf(filterFunc FilterFunc[T])

	// Len returns the number of entities in the cache.
	Len() int

	// ForEach calls the given function for each entity in the cache.
	ForEach(func(entity T))
}

Cache is a simple key value store. They key is always a snowflake.ID. The cache provides a simple way to store and retrieve entities. But is not guaranteed to be thread safe as this depends on the underlying implementation.

func NewCache

func NewCache[T any](flags Flags, neededFlags Flags, policy Policy[T]) Cache[T]

NewCache returns a new DefaultCache implementation which filter the entities after the gives Flags and Policy. This cache implementation is thread safe and can be used in multiple goroutines without any issues. It also only hands out copies to the entities. Regardless these entities should be handles as immutable.

type Caches

type Caches interface {
	SelfUserCache
	GuildCache
	ChannelCache
	StageInstanceCache
	GuildScheduledEventCache
	RoleCache
	MemberCache
	ThreadMemberCache
	PresenceCache
	VoiceStateCache
	MessageCache
	EmojiCache
	StickerCache

	// CacheFlags returns the current configured FLags of the caches.
	CacheFlags() Flags

	// MemberPermissions returns the calculated permissions of the given member.
	// This requires the FlagRoles to be set.
	MemberPermissions(member discord.Member) discord.Permissions

	// MemberPermissionsInChannel returns the calculated permissions of the given member in the given channel.
	// This requires the FlagRoles and FlagChannels to be set.
	MemberPermissionsInChannel(channel discord.GuildChannel, member discord.Member) discord.Permissions

	// MemberRoles returns all roles of the given member.
	// This requires the FlagRoles to be set.
	MemberRoles(member discord.Member) []discord.Role

	// AudioChannelMembers returns all members which are in the given audio channel.
	// This requires the FlagVoiceStates to be set.
	AudioChannelMembers(channel discord.GuildAudioChannel) []discord.Member

	// SelfMember returns the current bot member from the given guildID.
	// This is only available after we received the gateway.EventTypeGuildCreate event for the given guildID.
	SelfMember(guildID snowflake.ID) (discord.Member, bool)

	// GuildThreadsInChannel returns all discord.GuildThread from the ChannelCache and a bool indicating if it exists.
	GuildThreadsInChannel(channelID snowflake.ID) []discord.GuildThread

	// GuildMessageChannel returns a discord.GuildMessageChannel from the ChannelCache and a bool indicating if it exists.
	GuildMessageChannel(channelID snowflake.ID) (discord.GuildMessageChannel, bool)

	// GuildThread returns a discord.GuildThread from the ChannelCache and a bool indicating if it exists.
	GuildThread(channelID snowflake.ID) (discord.GuildThread, bool)

	// GuildAudioChannel returns a discord.GetGuildAudioChannel from the ChannelCache and a bool indicating if it exists.
	GuildAudioChannel(channelID snowflake.ID) (discord.GuildAudioChannel, bool)

	// GuildTextChannel returns a discord.GuildTextChannel from the ChannelCache and a bool indicating if it exists.
	GuildTextChannel(channelID snowflake.ID) (discord.GuildTextChannel, bool)

	// GuildVoiceChannel returns a discord.GuildVoiceChannel from the ChannelCache and a bool indicating if it exists.
	GuildVoiceChannel(channelID snowflake.ID) (discord.GuildVoiceChannel, bool)

	// GuildCategoryChannel returns a discord.GuildCategoryChannel from the ChannelCache and a bool indicating if it exists.
	GuildCategoryChannel(channelID snowflake.ID) (discord.GuildCategoryChannel, bool)

	// GuildNewsChannel returns a discord.GuildNewsChannel from the ChannelCache and a bool indicating if it exists.
	GuildNewsChannel(channelID snowflake.ID) (discord.GuildNewsChannel, bool)

	// GuildNewsThread returns a discord.GuildThread from the ChannelCache and a bool indicating if it exists.
	GuildNewsThread(channelID snowflake.ID) (discord.GuildThread, bool)

	// GuildPublicThread returns a discord.GuildThread from the ChannelCache and a bool indicating if it exists.
	GuildPublicThread(channelID snowflake.ID) (discord.GuildThread, bool)

	// GuildPrivateThread returns a discord.GuildThread from the ChannelCache and a bool indicating if it exists.
	GuildPrivateThread(channelID snowflake.ID) (discord.GuildThread, bool)

	// GuildStageVoiceChannel returns a discord.GuildStageVoiceChannel from the ChannelCache and a bool indicating if it exists.
	GuildStageVoiceChannel(channelID snowflake.ID) (discord.GuildStageVoiceChannel, bool)

	// GuildForumChannel returns a discord.GuildForumChannel from the ChannelCache and a bool indicating if it exists.
	GuildForumChannel(channelID snowflake.ID) (discord.GuildForumChannel, bool)
}

Caches combines all different entity caches into one with some utility methods.

func New

func New(opts ...ConfigOpt) Caches

New returns a new default Caches instance with the given ConfigOpt(s) applied.

type ChannelCache

type ChannelCache interface {
	Channel(channelID snowflake.ID) (discord.GuildChannel, bool)
	ChannelsForEach(fn func(channel discord.GuildChannel))
	ChannelsLen() int
	AddChannel(channel discord.GuildChannel)
	RemoveChannel(channelID snowflake.ID) (discord.GuildChannel, bool)
	RemoveChannelsByGuildID(guildID snowflake.ID)
}

func NewChannelCache

func NewChannelCache(cache Cache[discord.GuildChannel]) ChannelCache

type Config

type Config struct {
	CacheFlags Flags

	SelfUserCache SelfUserCache

	GuildCache       GuildCache
	GuildCachePolicy Policy[discord.Guild]

	ChannelCache       ChannelCache
	ChannelCachePolicy Policy[discord.GuildChannel]

	StageInstanceCache       StageInstanceCache
	StageInstanceCachePolicy Policy[discord.StageInstance]

	GuildScheduledEventCache       GuildScheduledEventCache
	GuildScheduledEventCachePolicy Policy[discord.GuildScheduledEvent]

	RoleCache       RoleCache
	RoleCachePolicy Policy[discord.Role]

	MemberCache       MemberCache
	MemberCachePolicy Policy[discord.Member]

	ThreadMemberCache       ThreadMemberCache
	ThreadMemberCachePolicy Policy[discord.ThreadMember]

	PresenceCache       PresenceCache
	PresenceCachePolicy Policy[discord.Presence]

	VoiceStateCache       VoiceStateCache
	VoiceStateCachePolicy Policy[discord.VoiceState]

	MessageCache       MessageCache
	MessageCachePolicy Policy[discord.Message]

	EmojiCache       EmojiCache
	EmojiCachePolicy Policy[discord.Emoji]

	StickerCache       StickerCache
	StickerCachePolicy Policy[discord.Sticker]
}

Config lets you configure your Caches instance.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config with sensible defaults.

func (*Config) Apply

func (c *Config) Apply(opts []ConfigOpt)

Apply applies the given ConfigOpt(s) to the Config

type ConfigOpt

type ConfigOpt func(config *Config)

ConfigOpt is a type alias for a function that takes a Config and is used to configure your Caches.

func WithCaches

func WithCaches(flags ...Flags) ConfigOpt

WithCaches sets the Flags of the Config.

func WithChannelCache

func WithChannelCache(channelCache ChannelCache) ConfigOpt

WithChannelCache sets the ChannelCache of the Config.

func WithChannelCachePolicy

func WithChannelCachePolicy(policy Policy[discord.GuildChannel]) ConfigOpt

WithChannelCachePolicy sets the Policy[discord.Channel] of the Config.

func WithEmojiCache

func WithEmojiCache(emojiCache EmojiCache) ConfigOpt

WithEmojiCache sets the EmojiCache of the Config.

func WithEmojiCachePolicy

func WithEmojiCachePolicy(policy Policy[discord.Emoji]) ConfigOpt

WithEmojiCachePolicy sets the Policy[discord.Emoji] of the Config.

func WithGuildCache

func WithGuildCache(guildCache GuildCache) ConfigOpt

WithGuildCache sets the GuildCache of the Config.

func WithGuildCachePolicy

func WithGuildCachePolicy(policy Policy[discord.Guild]) ConfigOpt

WithGuildCachePolicy sets the Policy[discord.Guild] of the Config.

func WithGuildScheduledEventCache

func WithGuildScheduledEventCache(guildScheduledEventCache GuildScheduledEventCache) ConfigOpt

WithGuildScheduledEventCache sets the GuildScheduledEventCache of the Config.

func WithGuildScheduledEventCachePolicy

func WithGuildScheduledEventCachePolicy(policy Policy[discord.GuildScheduledEvent]) ConfigOpt

WithGuildScheduledEventCachePolicy sets the Policy[discord.GuildScheduledEvent] of the Config.

func WithMemberCache

func WithMemberCache(memberCache MemberCache) ConfigOpt

WithMemberCache sets the MemberCache of the Config.

func WithMemberCachePolicy

func WithMemberCachePolicy(policy Policy[discord.Member]) ConfigOpt

WithMemberCachePolicy sets the Policy[discord.Member] of the Config.

func WithMessageCache

func WithMessageCache(messageCache MessageCache) ConfigOpt

WithMessageCache sets the MessageCache of the Config.

func WithMessageCachePolicy

func WithMessageCachePolicy(policy Policy[discord.Message]) ConfigOpt

WithMessageCachePolicy sets the Policy[discord.Message] of the Config.

func WithPresenceCache

func WithPresenceCache(presenceCache PresenceCache) ConfigOpt

WithPresenceCache sets the PresenceCache of the Config.

func WithPresenceCachePolicy

func WithPresenceCachePolicy(policy Policy[discord.Presence]) ConfigOpt

WithPresenceCachePolicy sets the Policy[discord.Presence] of the Config.

func WithRoleCache

func WithRoleCache(roleCache RoleCache) ConfigOpt

WithRoleCache sets the RoleCache of the Config.

func WithRoleCachePolicy

func WithRoleCachePolicy(policy Policy[discord.Role]) ConfigOpt

WithRoleCachePolicy sets the Policy[discord.Role] of the Config.

func WithStageInstanceCache

func WithStageInstanceCache(stageInstanceCache StageInstanceCache) ConfigOpt

WithStageInstanceCache sets the StageInstanceCache of the Config.

func WithStageInstanceCachePolicy

func WithStageInstanceCachePolicy(policy Policy[discord.StageInstance]) ConfigOpt

WithStageInstanceCachePolicy sets the Policy[discord.Guild] of the Config.

func WithStickerCache

func WithStickerCache(stickerCache StickerCache) ConfigOpt

WithStickerCache sets the StickerCache of the Config.

func WithStickerCachePolicy

func WithStickerCachePolicy(policy Policy[discord.Sticker]) ConfigOpt

WithStickerCachePolicy sets the Policy[discord.Sticker] of the Config.

func WithThreadMemberCache

func WithThreadMemberCache(threadMemberCache ThreadMemberCache) ConfigOpt

WithThreadMemberCache sets the ThreadMemberCache of the Config.

func WithThreadMemberCachePolicy

func WithThreadMemberCachePolicy(policy Policy[discord.ThreadMember]) ConfigOpt

WithThreadMemberCachePolicy sets the Policy[discord.ThreadMember] of the Config.

func WithVoiceStateCache

func WithVoiceStateCache(voiceStateCache VoiceStateCache) ConfigOpt

WithVoiceStateCache sets the VoiceStateCache of the Config.

func WithVoiceStateCachePolicy

func WithVoiceStateCachePolicy(policy Policy[discord.VoiceState]) ConfigOpt

WithVoiceStateCachePolicy sets the Policy[discord.VoiceState] of the Config.

type DefaultCache

type DefaultCache[T any] struct {
	// contains filtered or unexported fields
}

DefaultCache is a simple thread safe cache key value store.

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]) Len

func (c *DefaultCache[T]) Len() int

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 EmojiCache

type EmojiCache interface {
	Emoji(guildID snowflake.ID, emojiID snowflake.ID) (discord.Emoji, bool)
	EmojisForEach(guildID snowflake.ID, fn func(emoji discord.Emoji))
	EmojisAllLen() int
	EmojisLen(guildID snowflake.ID) int
	AddEmoji(emoji discord.Emoji)
	RemoveEmoji(guildID snowflake.ID, emojiID snowflake.ID) (discord.Emoji, bool)
	RemoveEmojisByGuildID(guildID snowflake.ID)
}

func NewEmojiCache

func NewEmojiCache(cache GroupedCache[discord.Emoji]) EmojiCache

type FilterFunc

type FilterFunc[T any] func(T) bool

FilterFunc is used to filter cached entities.

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
	FlagsAll        = FlagGuilds |
		FlagGuildScheduledEvents |
		FlagMembers |
		FlagThreadMembers |
		FlagMessages |
		FlagPresences |
		FlagChannels |
		FlagRoles |
		FlagEmojis |
		FlagStickers |
		FlagVoiceStates |
		FlagStageInstances
)

values for CacheFlags

func (Flags) Add

func (f Flags) Add(bits ...Flags) Flags

Add allows you to add multiple bits together, producing a new bit

func (Flags) Has

func (f Flags) Has(bits ...Flags) bool

Has will ensure that the bit includes all the bits entered

func (Flags) Missing

func (f Flags) Missing(bits ...Flags) bool

Missing will check whether the bit is missing any one of the bits

func (Flags) Remove

func (f Flags) Remove(bits ...Flags) Flags

Remove allows you to subtract multiple bits from the first, producing a new bit

type GroupedCache

type GroupedCache[T any] interface {
	// Get returns a copy of the entity with the given groupID and ID and a bool wheaten it was found or not.
	Get(groupID snowflake.ID, id snowflake.ID) (T, bool)

	// Put stores the given entity with the given groupID and ID as key. If the entity is already present, it will be overwritten.
	Put(groupID snowflake.ID, id snowflake.ID, entity T)

	// Remove removes the entity with the given groupID and ID as key and returns a copy of the entity and a bool whether it was removed or not.
	Remove(groupID snowflake.ID, id snowflake.ID) (T, bool)

	// GroupRemove removes all entities in the given groupID.
	GroupRemove(groupID snowflake.ID)

	// RemoveIf removes all entities that pass the given GroupedFilterFunc.
	RemoveIf(filterFunc GroupedFilterFunc[T])

	// GroupRemoveIf removes all entities that pass the given GroupedFilterFunc within the groupID.
	GroupRemoveIf(groupID snowflake.ID, filterFunc GroupedFilterFunc[T])

	// Len returns the total number of entities in the cache.
	Len() int

	// GroupLen returns the number of entities in the cache within the groupID.
	GroupLen(groupID snowflake.ID) int

	// ForEach calls the given function for each entity in the cache.
	ForEach(func(groupID snowflake.ID, entity T))

	// GroupForEach calls the given function for each entity in the cache within the groupID.
	GroupForEach(groupID snowflake.ID, forEachFunc func(entity T))
}

GroupedCache is a simple key value store grouped by a snowflake.ID. They key is always a snowflake.ID. The cache provides a simple way to store and retrieve entities. But is not guaranteed to be thread safe as this depends on the underlying implementation.

func NewGroupedCache

func NewGroupedCache[T any](flags Flags, neededFlags Flags, policy Policy[T]) GroupedCache[T]

NewGroupedCache returns a new default GroupedCache with the provided flags, neededFlags and policy.

type GroupedFilterFunc

type GroupedFilterFunc[T any] func(groupID snowflake.ID, entity T) bool

GroupedFilterFunc is used to filter grouped cached entities.

type GuildCache

type GuildCache interface {
	IsGuildUnready(guildID snowflake.ID) bool
	SetGuildUnready(guildID snowflake.ID, unready bool)
	UnreadyGuildIDs() []snowflake.ID

	IsGuildUnavailable(guildID snowflake.ID) bool
	SetGuildUnavailable(guildID snowflake.ID, unavailable bool)
	UnavailableGuildIDs() []snowflake.ID

	Guild(guildID snowflake.ID) (discord.Guild, bool)
	GuildsForEach(fn func(guild discord.Guild))
	GuildsLen() int
	AddGuild(guild discord.Guild)
	RemoveGuild(guildID snowflake.ID) (discord.Guild, bool)
}

func NewGuildCache

func NewGuildCache(cache Cache[discord.Guild], unreadyGuilds Set[snowflake.ID], unavailableGuilds Set[snowflake.ID]) GuildCache

type GuildScheduledEventCache

type GuildScheduledEventCache interface {
	GuildScheduledEvent(guildID snowflake.ID, guildScheduledEventID snowflake.ID) (discord.GuildScheduledEvent, bool)
	GuildScheduledEventsForEach(guildID snowflake.ID, fn func(guildScheduledEvent discord.GuildScheduledEvent))
	GuildScheduledEventsAllLen() int
	GuildScheduledEventsLen(guildID snowflake.ID) int
	AddGuildScheduledEvent(guildScheduledEvent discord.GuildScheduledEvent)
	RemoveGuildScheduledEvent(guildID snowflake.ID, guildScheduledEventID snowflake.ID) (discord.GuildScheduledEvent, bool)
	RemoveGuildScheduledEventsByGuildID(guildID snowflake.ID)
}

type MemberCache

type MemberCache interface {
	Member(guildID snowflake.ID, userID snowflake.ID) (discord.Member, bool)
	MembersForEach(guildID snowflake.ID, fn func(member discord.Member))
	MembersAllLen() int
	MembersLen(guildID snowflake.ID) int
	AddMember(member discord.Member)
	RemoveMember(guildID snowflake.ID, userID snowflake.ID) (discord.Member, bool)
	RemoveMembersByGuildID(guildID snowflake.ID)
}

func NewMemberCache

func NewMemberCache(cache GroupedCache[discord.Member]) MemberCache

type MessageCache

type MessageCache interface {
	Message(channelID snowflake.ID, messageID snowflake.ID) (discord.Message, bool)
	MessagesForEach(channelID snowflake.ID, fn func(message discord.Message))
	MessagesAllLen() int
	MessagesLen(guildID snowflake.ID) int
	AddMessage(message discord.Message)
	RemoveMessage(channelID snowflake.ID, messageID snowflake.ID) (discord.Message, bool)
	RemoveMessagesByChannelID(channelID snowflake.ID)
	RemoveMessagesByGuildID(guildID snowflake.ID)
}

func NewMessageCache

func NewMessageCache(cache GroupedCache[discord.Message]) MessageCache

type Policy

type Policy[T any] func(entity T) bool

Policy can be used to define your own policy for when entities should be cached.

func AllPolicies

func AllPolicies[T any](policies ...Policy[T]) Policy[T]

AllPolicies is a shorthand for CachePolicy.And(CachePolicy).And(CachePolicy) etc.

func AnyPolicy

func AnyPolicy[T any](policies ...Policy[T]) Policy[T]

AnyPolicy is a shorthand for CachePolicy.Or(CachePolicy).Or(CachePolicy) etc.

func PolicyChannelExclude

func PolicyChannelExclude(channelTypes ...discord.ChannelType) Policy[discord.Channel]

PolicyChannelExclude returns a policy that will not cache channels of the given types.

func PolicyChannelInclude

func PolicyChannelInclude(channelTypes ...discord.ChannelType) Policy[discord.Channel]

PolicyChannelInclude returns a policy that will only cache channels of the given types.

func PolicyMembersInVoice

func PolicyMembersInVoice(caches Caches) Policy[discord.Member]

PolicyMembersInVoice returns a policy that will only cache members that are connected to an audio channel.

func PolicyMembersInclude

func PolicyMembersInclude(guildIDs ...snowflake.ID) Policy[discord.Member]

PolicyMembersInclude returns a policy that will only cache members of the given guilds.

func (Policy[T]) And

func (p Policy[T]) And(policy Policy[T]) Policy[T]

And allows you to require both CachePolicy(s) to be true for the entity to be cached

func (Policy[T]) Or

func (p Policy[T]) Or(policy Policy[T]) Policy[T]

Or allows you to combine the CachePolicy with another, meaning either of them needs to be true

type PresenceCache

type PresenceCache interface {
	Presence(guildID snowflake.ID, userID snowflake.ID) (discord.Presence, bool)
	PresenceForEach(guildID snowflake.ID, fn func(presence discord.Presence))
	PresencesAllLen() int
	PresencesLen(guildID snowflake.ID) int
	AddPresence(presence discord.Presence)
	RemovePresence(guildID snowflake.ID, userID snowflake.ID) (discord.Presence, bool)
	RemovePresencesByGuildID(guildID snowflake.ID)
}

func NewPresenceCache

func NewPresenceCache(cache GroupedCache[discord.Presence]) PresenceCache

type RoleCache

type RoleCache interface {
	Role(guildID snowflake.ID, roleID snowflake.ID) (discord.Role, bool)
	RolesForEach(guildID snowflake.ID, fn func(role discord.Role))
	RolesAllLen() int
	RolesLen(guildID snowflake.ID) int
	AddRole(role discord.Role)
	RemoveRole(guildID snowflake.ID, roleID snowflake.ID) (discord.Role, bool)
	RemoveRolesByGuildID(guildID snowflake.ID)
}

func NewRoleCache

func NewRoleCache(cache GroupedCache[discord.Role]) RoleCache

type SelfUserCache

type SelfUserCache interface {
	SelfUser() (discord.OAuth2User, bool)
	SetSelfUser(selfUser discord.OAuth2User)
}

func NewSelfUserCache

func NewSelfUserCache() SelfUserCache

type Set

type Set[T comparable] interface {
	// Add adds an item to the set.
	Add(item T)
	// Remove removes an item from the set.
	Remove(item T)
	// Has returns true if the item is in the set, false otherwise.
	Has(item T) bool
	// Len returns the number of items in the set.
	Len() int
	// Clear removes all items from the set.
	Clear()
	// ForEach iterates over the items in the set.
	ForEach(f func(item T))
}

Set is a collection of unique items. It should be thread-safe.

func NewSet

func NewSet[T comparable]() Set[T]

NewSet returns a thread-safe in memory implementation of a set.

type StageInstanceCache

type StageInstanceCache interface {
	StageInstance(guildID snowflake.ID, stageInstanceID snowflake.ID) (discord.StageInstance, bool)
	StageInstanceForEach(guildID snowflake.ID, fn func(stageInstance discord.StageInstance))
	StageInstancesAllLen() int
	StageInstancesLen(guildID snowflake.ID) int
	AddStageInstance(stageInstance discord.StageInstance)
	RemoveStageInstance(guildID snowflake.ID, stageInstanceID snowflake.ID) (discord.StageInstance, bool)
	RemoveStageInstancesByGuildID(guildID snowflake.ID)
}

type StickerCache

type StickerCache interface {
	Sticker(guildID snowflake.ID, stickerID snowflake.ID) (discord.Sticker, bool)
	StickersForEach(guildID snowflake.ID, fn func(sticker discord.Sticker))
	StickersAllLen() int
	StickersLen(guildID snowflake.ID) int
	AddSticker(sticker discord.Sticker)
	RemoveSticker(guildID snowflake.ID, stickerID snowflake.ID) (discord.Sticker, bool)
	RemoveStickersByGuildID(guildID snowflake.ID)
}

func NewStickerCache

func NewStickerCache(cache GroupedCache[discord.Sticker]) StickerCache

type ThreadMemberCache

type ThreadMemberCache interface {
	ThreadMember(threadID snowflake.ID, userID snowflake.ID) (discord.ThreadMember, bool)
	ThreadMemberForEach(threadID snowflake.ID, fn func(threadMember discord.ThreadMember))
	ThreadMembersAllLen() int
	ThreadMembersLen(guildID snowflake.ID) int
	AddThreadMember(threadMember discord.ThreadMember)
	RemoveThreadMember(threadID snowflake.ID, userID snowflake.ID) (discord.ThreadMember, bool)
	RemoveThreadMembersByThreadID(threadID snowflake.ID)
}

type VoiceStateCache

type VoiceStateCache interface {
	VoiceState(guildID snowflake.ID, userID snowflake.ID) (discord.VoiceState, bool)
	VoiceStatesForEach(guildID snowflake.ID, fn func(discord.VoiceState))
	VoiceStatesAllLen() int
	VoiceStatesLen(guildID snowflake.ID) int
	AddVoiceState(voiceState discord.VoiceState)
	RemoveVoiceState(guildID snowflake.ID, userID snowflake.ID) (discord.VoiceState, bool)
	RemoveVoiceStatesByGuildID(guildID snowflake.ID)
}

func NewVoiceStateCache

func NewVoiceStateCache(cache GroupedCache[discord.VoiceState]) VoiceStateCache

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL