cache

package
v0.0.0-...-7f71e2c Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: BSD-3-Clause Imports: 20 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("object not found in cache")

Functions

This section is empty.

Types

type BoltCache

type BoltCache struct {
	*bolt.DB
	// contains filtered or unexported fields
}

BoltCache Deprecated

func NewBoltCache

func NewBoltCache(cacheOptions CacheOptions, boltOptions BoltOptions) BoltCache

func (*BoltCache) DeleteChannel

func (c *BoltCache) DeleteChannel(channelId uint64)

func (*BoltCache) DeleteEmoji

func (c *BoltCache) DeleteEmoji(emojiId uint64)

func (*BoltCache) DeleteGuild

func (c *BoltCache) DeleteGuild(guildId uint64)

func (*BoltCache) DeleteGuildChannels

func (c *BoltCache) DeleteGuildChannels(guildId uint64)

func (*BoltCache) DeleteGuildRoles

func (c *BoltCache) DeleteGuildRoles(guildId uint64)

func (*BoltCache) DeleteMember

func (c *BoltCache) DeleteMember(userId, guildId uint64)

func (*BoltCache) DeleteRole

func (c *BoltCache) DeleteRole(roleId uint64)

func (*BoltCache) DeleteVoiceState

func (c *BoltCache) DeleteVoiceState(userId, guildId uint64)

func (*BoltCache) GetChannel

func (c *BoltCache) GetChannel(channelId uint64) (channel.Channel, bool)

func (*BoltCache) GetEmoji

func (c *BoltCache) GetEmoji(emojiId uint64) (emoji.Emoji, bool)

func (*BoltCache) GetGuild

func (c *BoltCache) GetGuild(guildId uint64) (guild.Guild, bool)

func (*BoltCache) GetGuildChannels

func (c *BoltCache) GetGuildChannels(guildId uint64) []channel.Channel

func (*BoltCache) GetGuildCount

func (c *BoltCache) GetGuildCount() int

func (*BoltCache) GetGuildEmojis

func (c *BoltCache) GetGuildEmojis(guildId uint64) []emoji.Emoji

func (*BoltCache) GetGuildMembers

func (c *BoltCache) GetGuildMembers(guildId uint64, withUserData bool) []member.Member

func (*BoltCache) GetGuildOwner

func (c *BoltCache) GetGuildOwner(guildId uint64) (uint64, bool)

func (*BoltCache) GetGuildRoles

func (c *BoltCache) GetGuildRoles(guildId uint64) []guild.Role

func (*BoltCache) GetGuildVoiceStates

func (c *BoltCache) GetGuildVoiceStates(guildId uint64) []guild.VoiceState

func (*BoltCache) GetGuilds

func (c *BoltCache) GetGuilds() []guild.Guild

func (*BoltCache) GetMember

func (c *BoltCache) GetMember(guildId, userId uint64) (member.Member, bool)

func (*BoltCache) GetOptions

func (c *BoltCache) GetOptions() CacheOptions

func (*BoltCache) GetRole

func (c *BoltCache) GetRole(roleId uint64) (guild.Role, bool)

func (*BoltCache) GetRoles

func (c *BoltCache) GetRoles(guildId uint64, ids []uint64) (map[uint64]guild.Role, error)

func (*BoltCache) GetSelf

func (c *BoltCache) GetSelf() (user.User, bool)

func (*BoltCache) GetUser

func (c *BoltCache) GetUser(userId uint64) (user.User, bool)

func (*BoltCache) GetUsers

func (c *BoltCache) GetUsers(ids []uint64) (map[uint64]user.User, error)

func (*BoltCache) GetVoiceState

func (c *BoltCache) GetVoiceState(userId, guildId uint64) (guild.VoiceState, bool)

func (*BoltCache) StoreChannel

func (c *BoltCache) StoreChannel(ch channel.Channel)

func (*BoltCache) StoreChannels

func (c *BoltCache) StoreChannels(channels []channel.Channel)

func (*BoltCache) StoreEmoji

func (c *BoltCache) StoreEmoji(e emoji.Emoji, guildId uint64)

func (*BoltCache) StoreEmojis

func (c *BoltCache) StoreEmojis(emojis []emoji.Emoji, guildId uint64)

func (*BoltCache) StoreGuild

func (c *BoltCache) StoreGuild(g guild.Guild)

func (*BoltCache) StoreGuilds

func (c *BoltCache) StoreGuilds(guilds []guild.Guild)

func (*BoltCache) StoreMember

func (c *BoltCache) StoreMember(m member.Member, guildId uint64)

func (*BoltCache) StoreMembers

func (c *BoltCache) StoreMembers(members []member.Member, guildId uint64)

func (*BoltCache) StoreRole

func (c *BoltCache) StoreRole(role guild.Role, guildId uint64)

func (*BoltCache) StoreRoles

func (c *BoltCache) StoreRoles(roles []guild.Role, guildId uint64)

func (*BoltCache) StoreSelf

func (c *BoltCache) StoreSelf(self user.User)

func (*BoltCache) StoreUser

func (c *BoltCache) StoreUser(u user.User)

func (*BoltCache) StoreUsers

func (c *BoltCache) StoreUsers(users []user.User)

func (*BoltCache) StoreVoiceState

func (c *BoltCache) StoreVoiceState(state guild.VoiceState)

func (*BoltCache) StoreVoiceStates

func (c *BoltCache) StoreVoiceStates(states []guild.VoiceState)

type BoltOptions

type BoltOptions struct {
	ClearOnRestart bool
	Path           string
	FileMode       os.FileMode
	*bolt.Options
}

type Cache

type Cache interface {
	Options() CacheOptions

	StoreUser(ctx context.Context, user user.User) error
	StoreUsers(ctx context.Context, user []user.User) error
	GetUser(ctx context.Context, id uint64) (user.User, error)
	GetUsers(ctx context.Context, ids []uint64) (map[uint64]user.User, error)

	StoreGuild(ctx context.Context, guild guild.Guild) error
	StoreGuilds(ctx context.Context, guilds []guild.Guild) error
	GetGuild(ctx context.Context, id uint64) (guild.Guild, error)
	DeleteGuild(ctx context.Context, id uint64) error
	GetGuildCount(ctx context.Context) (int, error)
	GetGuildOwner(ctx context.Context, guildId uint64) (uint64, error)

	StoreMember(ctx context.Context, member member.Member, guildId uint64) error
	StoreMembers(ctx context.Context, members []member.Member, guildId uint64) error
	GetMember(ctx context.Context, guildId, userId uint64) (member.Member, error)
	GetGuildMembers(ctx context.Context, guildId uint64, withUserData bool) ([]member.Member, error)
	DeleteMember(ctx context.Context, userId, guildId uint64) error

	StoreChannel(ctx context.Context, channel channel.Channel) error
	StoreChannels(ctx context.Context, channel []channel.Channel) error
	GetChannel(ctx context.Context, id uint64) (channel.Channel, error)
	GetGuildChannels(ctx context.Context, guildId uint64) ([]channel.Channel, error)
	DeleteChannel(ctx context.Context, channelId uint64) error
	DeleteGuildChannels(ctx context.Context, guildId uint64) error

	StoreRole(ctx context.Context, role guild.Role, guildId uint64) error
	StoreRoles(ctx context.Context, roles []guild.Role, guildId uint64) error
	GetRole(ctx context.Context, id uint64) (guild.Role, error)
	GetRoles(ctx context.Context, guildId uint64, ids []uint64) (map[uint64]guild.Role, error)
	GetGuildRoles(ctx context.Context, guildId uint64) ([]guild.Role, error)
	DeleteRole(ctx context.Context, roleId uint64) error
	DeleteGuildRoles(ctx context.Context, guildId uint64) error

	StoreEmoji(ctx context.Context, emoji emoji.Emoji, guildId uint64) error
	StoreEmojis(ctx context.Context, emojis []emoji.Emoji, guildId uint64) error
	GetEmoji(ctx context.Context, id uint64) (emoji.Emoji, error)
	GetGuildEmojis(ctx context.Context, id uint64) ([]emoji.Emoji, error)
	DeleteEmoji(ctx context.Context, emojiId uint64) error

	StoreVoiceState(ctx context.Context, voiceState guild.VoiceState) error
	StoreVoiceStates(ctx context.Context, voiceStates []guild.VoiceState) error
	GetVoiceState(ctx context.Context, userId, guildId uint64) (guild.VoiceState, error)
	GetGuildVoiceStates(ctx context.Context, guildId uint64) ([]guild.VoiceState, error)
	DeleteVoiceState(ctx context.Context, userId, guildId uint64) error

	StoreSelf(ctx context.Context, self user.User) error
	GetSelf(ctx context.Context) (user.User, error)
}

type CacheFactory

type CacheFactory func() Cache

func MemoryCacheFactory

func MemoryCacheFactory(cacheOptions CacheOptions) CacheFactory

func PgCacheFactory

func PgCacheFactory(db *pgxpool.Pool, options CacheOptions) CacheFactory

type CacheOptions

type CacheOptions struct {
	Guilds      bool
	Users       bool
	Members     bool // requires Guilds = true
	Channels    bool // requires Guilds = true
	Roles       bool // requires Guilds = true
	Emojis      bool // requires Guilds = true
	VoiceStates bool
}

type MemoryCache

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

func NewMemoryCache

func NewMemoryCache(cacheOptions CacheOptions) MemoryCache

func (*MemoryCache) DeleteChannel

func (c *MemoryCache) DeleteChannel(ctx context.Context, channelId uint64) error

func (*MemoryCache) DeleteEmoji

func (c *MemoryCache) DeleteEmoji(ctx context.Context, emojiId uint64) error

func (*MemoryCache) DeleteGuild

func (c *MemoryCache) DeleteGuild(ctx context.Context, guildId uint64) error

func (*MemoryCache) DeleteGuildChannels

func (c *MemoryCache) DeleteGuildChannels(ctx context.Context, guildId uint64) error

func (*MemoryCache) DeleteGuildRoles

func (c *MemoryCache) DeleteGuildRoles(ctx context.Context, guildId uint64) error

func (*MemoryCache) DeleteMember

func (c *MemoryCache) DeleteMember(ctx context.Context, userId, guildId uint64) error

func (*MemoryCache) DeleteRole

func (c *MemoryCache) DeleteRole(ctx context.Context, roleId uint64) error

func (*MemoryCache) DeleteVoiceState

func (c *MemoryCache) DeleteVoiceState(ctx context.Context, userId, guildId uint64) error

func (*MemoryCache) GetChannel

func (c *MemoryCache) GetChannel(ctx context.Context, channelId uint64) (channel.Channel, error)

func (*MemoryCache) GetEmoji

func (c *MemoryCache) GetEmoji(ctx context.Context, emojiId uint64) (emoji.Emoji, error)

func (*MemoryCache) GetGuild

func (c *MemoryCache) GetGuild(ctx context.Context, guildId uint64) (guild.Guild, error)

func (*MemoryCache) GetGuildChannels

func (c *MemoryCache) GetGuildChannels(ctx context.Context, guildId uint64) ([]channel.Channel, error)

func (*MemoryCache) GetGuildCount

func (c *MemoryCache) GetGuildCount(ctx context.Context) (int, error)

func (*MemoryCache) GetGuildEmojis

func (c *MemoryCache) GetGuildEmojis(ctx context.Context, guildId uint64) ([]emoji.Emoji, error)

func (*MemoryCache) GetGuildMembers

func (c *MemoryCache) GetGuildMembers(ctx context.Context, guildId uint64, withUserData bool) ([]member.Member, error)

func (*MemoryCache) GetGuildOwner

func (c *MemoryCache) GetGuildOwner(ctx context.Context, guildId uint64) (uint64, error)

func (*MemoryCache) GetGuildRoles

func (c *MemoryCache) GetGuildRoles(ctx context.Context, guildId uint64) ([]guild.Role, error)

func (*MemoryCache) GetGuildVoiceStates

func (c *MemoryCache) GetGuildVoiceStates(ctx context.Context, guildId uint64) ([]guild.VoiceState, error)

func (*MemoryCache) GetMember

func (c *MemoryCache) GetMember(ctx context.Context, guildId, userId uint64) (member.Member, error)

func (*MemoryCache) GetRole

func (c *MemoryCache) GetRole(ctx context.Context, roleId uint64) (guild.Role, error)

func (*MemoryCache) GetRoles

func (c *MemoryCache) GetRoles(ctx context.Context, guildId uint64, ids []uint64) (map[uint64]guild.Role, error)

func (*MemoryCache) GetSelf

func (c *MemoryCache) GetSelf(ctx context.Context) (user.User, error)

func (*MemoryCache) GetUser

func (c *MemoryCache) GetUser(ctx context.Context, userId uint64) (user.User, error)

func (*MemoryCache) GetUsers

func (c *MemoryCache) GetUsers(ctx context.Context, ids []uint64) (map[uint64]user.User, error)

func (*MemoryCache) GetVoiceState

func (c *MemoryCache) GetVoiceState(ctx context.Context, userId, guildId uint64) (guild.VoiceState, error)

func (*MemoryCache) Options

func (c *MemoryCache) Options() CacheOptions

func (*MemoryCache) Size

func (c *MemoryCache) Size() string

func (*MemoryCache) StoreChannel

func (c *MemoryCache) StoreChannel(ctx context.Context, ch channel.Channel) error

func (*MemoryCache) StoreChannels

func (c *MemoryCache) StoreChannels(ctx context.Context, channels []channel.Channel) error

func (*MemoryCache) StoreEmoji

func (c *MemoryCache) StoreEmoji(ctx context.Context, e emoji.Emoji, guildId uint64) error

func (*MemoryCache) StoreEmojis

func (c *MemoryCache) StoreEmojis(ctx context.Context, emojis []emoji.Emoji, guildId uint64) error

func (*MemoryCache) StoreGuild

func (c *MemoryCache) StoreGuild(ctx context.Context, g guild.Guild) error

func (*MemoryCache) StoreGuilds

func (c *MemoryCache) StoreGuilds(ctx context.Context, guilds []guild.Guild) error

func (*MemoryCache) StoreMember

func (c *MemoryCache) StoreMember(ctx context.Context, m member.Member, guildId uint64) error

func (*MemoryCache) StoreMembers

func (c *MemoryCache) StoreMembers(ctx context.Context, members []member.Member, guildId uint64) error

func (*MemoryCache) StoreRole

func (c *MemoryCache) StoreRole(ctx context.Context, role guild.Role, guildId uint64) error

func (*MemoryCache) StoreRoles

func (c *MemoryCache) StoreRoles(ctx context.Context, roles []guild.Role, guildId uint64) error

func (*MemoryCache) StoreSelf

func (c *MemoryCache) StoreSelf(ctx context.Context, self user.User) error

func (*MemoryCache) StoreUser

func (c *MemoryCache) StoreUser(ctx context.Context, u user.User) error

func (*MemoryCache) StoreUsers

func (c *MemoryCache) StoreUsers(ctx context.Context, users []user.User) error

func (*MemoryCache) StoreVoiceState

func (c *MemoryCache) StoreVoiceState(ctx context.Context, state guild.VoiceState) error

func (*MemoryCache) StoreVoiceStates

func (c *MemoryCache) StoreVoiceStates(ctx context.Context, states []guild.VoiceState) error

type PgCache

type PgCache struct {
	*pgxpool.Pool
	// contains filtered or unexported fields
}

func NewPgCache

func NewPgCache(db *pgxpool.Pool, options CacheOptions) PgCache

func (*PgCache) CreateSchema

func (c *PgCache) CreateSchema(ctx context.Context) error

func (*PgCache) DeleteChannel

func (c *PgCache) DeleteChannel(ctx context.Context, channelId uint64) error

func (*PgCache) DeleteEmoji

func (c *PgCache) DeleteEmoji(ctx context.Context, emojiId uint64) error

func (*PgCache) DeleteGuild

func (c *PgCache) DeleteGuild(ctx context.Context, id uint64) error

func (*PgCache) DeleteGuildChannels

func (c *PgCache) DeleteGuildChannels(ctx context.Context, guildId uint64) error

func (*PgCache) DeleteGuildRoles

func (c *PgCache) DeleteGuildRoles(ctx context.Context, guildId uint64) error

func (*PgCache) DeleteMember

func (c *PgCache) DeleteMember(ctx context.Context, userId, guildId uint64) error

func (*PgCache) DeleteRole

func (c *PgCache) DeleteRole(ctx context.Context, roleId uint64) error

func (*PgCache) DeleteVoiceState

func (c *PgCache) DeleteVoiceState(ctx context.Context, userId, guildId uint64) error

func (*PgCache) GetChannel

func (c *PgCache) GetChannel(ctx context.Context, channelId uint64) (channel.Channel, error)

func (*PgCache) GetEmoji

func (c *PgCache) GetEmoji(ctx context.Context, id uint64) (emoji.Emoji, error)

func (*PgCache) GetGuild

func (c *PgCache) GetGuild(ctx context.Context, id uint64) (guild.Guild, error)

func (*PgCache) GetGuildChannels

func (c *PgCache) GetGuildChannels(ctx context.Context, guildId uint64) ([]channel.Channel, error)

func (*PgCache) GetGuildCount

func (c *PgCache) GetGuildCount(ctx context.Context) (int, error)

func (*PgCache) GetGuildEmojis

func (c *PgCache) GetGuildEmojis(ctx context.Context, guildId uint64) ([]emoji.Emoji, error)

func (*PgCache) GetGuildMembers

func (c *PgCache) GetGuildMembers(ctx context.Context, guildId uint64, withUserData bool) ([]member.Member, error)

func (*PgCache) GetGuildOwner

func (c *PgCache) GetGuildOwner(ctx context.Context, guildId uint64) (uint64, error)

func (*PgCache) GetGuildRole

func (c *PgCache) GetGuildRole(ctx context.Context, id, guildId uint64) (guild.Role, error)

func (*PgCache) GetGuildRoles

func (c *PgCache) GetGuildRoles(ctx context.Context, guildId uint64) ([]guild.Role, error)

func (*PgCache) GetGuildVoiceStates

func (c *PgCache) GetGuildVoiceStates(ctx context.Context, guildId uint64) ([]guild.VoiceState, error)

func (*PgCache) GetMember

func (c *PgCache) GetMember(ctx context.Context, guildId, userId uint64) (member.Member, error)

func (*PgCache) GetRole

func (c *PgCache) GetRole(ctx context.Context, id uint64) (guild.Role, error)

func (*PgCache) GetRoles

func (c *PgCache) GetRoles(ctx context.Context, guildId uint64, ids []uint64) (map[uint64]guild.Role, error)

func (*PgCache) GetSelf

func (c *PgCache) GetSelf(ctx context.Context) (user.User, error)

func (*PgCache) GetUser

func (c *PgCache) GetUser(ctx context.Context, id uint64) (user.User, error)

func (*PgCache) GetUsers

func (c *PgCache) GetUsers(ctx context.Context, ids []uint64) (map[uint64]user.User, error)

func (*PgCache) GetVoiceState

func (c *PgCache) GetVoiceState(ctx context.Context, userId, guildId uint64) (guild.VoiceState, error)

func (*PgCache) Options

func (c *PgCache) Options() CacheOptions

func (*PgCache) StoreChannel

func (c *PgCache) StoreChannel(ctx context.Context, ch channel.Channel) error

func (*PgCache) StoreChannels

func (c *PgCache) StoreChannels(ctx context.Context, channels []channel.Channel) error

func (*PgCache) StoreEmoji

func (c *PgCache) StoreEmoji(ctx context.Context, emoji emoji.Emoji, guildId uint64) error

func (*PgCache) StoreEmojis

func (c *PgCache) StoreEmojis(ctx context.Context, emojis []emoji.Emoji, guildId uint64) error

func (*PgCache) StoreGuild

func (c *PgCache) StoreGuild(ctx context.Context, g guild.Guild) error

func (*PgCache) StoreGuilds

func (c *PgCache) StoreGuilds(ctx context.Context, guilds []guild.Guild) error

func (*PgCache) StoreMember

func (c *PgCache) StoreMember(ctx context.Context, m member.Member, guildId uint64) error

func (*PgCache) StoreMembers

func (c *PgCache) StoreMembers(ctx context.Context, members []member.Member, guildId uint64) error

func (*PgCache) StoreRole

func (c *PgCache) StoreRole(ctx context.Context, role guild.Role, guildId uint64) error

func (*PgCache) StoreRoles

func (c *PgCache) StoreRoles(ctx context.Context, roles []guild.Role, guildId uint64) error

func (*PgCache) StoreSelf

func (c *PgCache) StoreSelf(ctx context.Context, self user.User) error

func (*PgCache) StoreUser

func (c *PgCache) StoreUser(ctx context.Context, user user.User) error

func (*PgCache) StoreUsers

func (c *PgCache) StoreUsers(ctx context.Context, users []user.User) error

func (*PgCache) StoreVoiceState

func (c *PgCache) StoreVoiceState(ctx context.Context, state guild.VoiceState) error

func (*PgCache) StoreVoiceStates

func (c *PgCache) StoreVoiceStates(ctx context.Context, states []guild.VoiceState) error

Jump to

Keyboard shortcuts

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