cache

package
v0.1.12 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultStore

type DefaultStore struct {
	// contains filtered or unexported fields
}

func NewDefaultStore

func NewDefaultStore() *DefaultStore

func (*DefaultStore) ChannelGuild

func (d *DefaultStore) ChannelGuild(channel snowflake.ID) snowflake.ID

func (*DefaultStore) Channels

func (*DefaultStore) Guilds

func (d *DefaultStore) Guilds() SafeStore[discord.Guild]

func (*DefaultStore) Members

func (*DefaultStore) Messages

func (d *DefaultStore) Messages() SafeStore[sets.Set[snowflake.ID, discord.BaseMessage]]

func (*DefaultStore) Presences

func (*DefaultStore) Private

func (d *DefaultStore) Private() SafeStore[discord.Channel]

func (*DefaultStore) Reactions

func (*DefaultStore) SetChannelGuild

func (d *DefaultStore) SetChannelGuild(channel, guild snowflake.ID)

func (*DefaultStore) Users

func (d *DefaultStore) Users() SafeStore[discord.User]

func (*DefaultStore) VoiceStates

func (d *DefaultStore) VoiceStates() SafeStore[SafeStore[discord.VoiceState]]

type SafeMap

type SafeMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewSafeMap

func NewSafeMap[K comparable, V any](prealloc int) *SafeMap[K, V]

func NewSafeMapWithInitializer

func NewSafeMapWithInitializer[K comparable, V any](prealloc int, init func() V) *SafeMap[K, V]

func (*SafeMap[K, V]) Delete

func (v *SafeMap[K, V]) Delete(key K) bool

func (*SafeMap[K, V]) Each

func (v *SafeMap[K, V]) Each(fn func(item V))

func (*SafeMap[K, V]) Filter

func (v *SafeMap[K, V]) Filter(fn func(item V) bool) (data []V)

func (*SafeMap[K, V]) Find

func (v *SafeMap[K, V]) Find(fn func(item V) bool) (_ V, found bool)

func (*SafeMap[K, V]) Get

func (v *SafeMap[K, V]) Get(key K) (value V, ok bool)

func (*SafeMap[K, V]) GetOrSet

func (v *SafeMap[K, V]) GetOrSet(key K, set func() V) V

func (*SafeMap[K, V]) Has

func (v *SafeMap[K, V]) Has(key K) bool

func (*SafeMap[K, V]) Set

func (v *SafeMap[K, V]) Set(key K, value V)

func (*SafeMap[K, V]) Size

func (v *SafeMap[K, V]) Size() int

func (*SafeMap[K, V]) Sort

func (v *SafeMap[K, V]) Sort(fn func(a, b V) bool) (sorted []V)

func (*SafeMap[K, V]) ToSlice

func (v *SafeMap[K, V]) ToSlice() (data []V)

func (*SafeMap[K, V]) UnsafeGet

func (v *SafeMap[K, V]) UnsafeGet(key K) V

type SafeStore

type SafeStore[V any] SafeStoreCustom[snowflake.ID, V]

type SafeStoreCustom

type SafeStoreCustom[K comparable, V any] interface {
	Get(key K) (val V, found bool)
	UnsafeGet(key K) V
	GetOrSet(key K, set func() V) V
	ToSlice() []V
	Filter(fn func(item V) bool) []V
	Each(fn func(item V))
	Find(fn func(item V) bool) (V, bool)
	Sort(fn func(a, b V) bool) []V
	Has(key K) bool
	Set(key K, value V)
	Delete(key K) bool
	Size() int
}

type Store

type Store interface {
	Guilds() SafeStore[discord.Guild]
	Members() SafeStore[SafeStore[discord.Member]]
	Channels() SafeStore[SafeStore[discord.Channel]]
	Reactions() SafeStore[SafeStoreCustom[string, discord.MessageReaction]]
	Presences() SafeStore[SafeStore[discord.BasePresence]]
	Messages() SafeStore[sets.Set[snowflake.ID, discord.BaseMessage]]
	Private() SafeStore[discord.Channel]
	Users() SafeStore[discord.User]
	VoiceStates() SafeStore[SafeStore[discord.VoiceState]]
	SetChannelGuild(channel, guild snowflake.ID)
	ChannelGuild(channel snowflake.ID) snowflake.ID
}

Jump to

Keyboard shortcuts

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