db

package
v0.44.18 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

The very core database/cache data operations package.

Index

Constants

This section is empty.

Variables

View Source
var (
	FlowCache         *core.Cache
	PollCache         *core.Cache
	RequestCache      *core.Cache
	SubscriptionCache *core.Cache
	TokenCache        *core.Cache
	UserCache         *core.Cache
)

Functions

func DeleteOne

func DeleteOne(cache *core.Cache, key string) bool

DeleteOne deletes an item from such cache via the requested key value. Fails if the database state is locked.

func DumpAll

func DumpAll() string

func GetAll

func GetAll[T any](cache *core.Cache, model T) (map[string]T, int)

GetAll function does a fetch-all operation on the given cache instance. After the data retrieval, all items are to be asserted their corresponding types and to be loaded into a map[string]T map, where T is a generic type. This map and number of processed items are returned.

func GetGravatarURL

func GetGravatarURL(user models.User, channel chan avatarResult, wg *sync.WaitGroup) string

GetGravatarURL function returns the avatar image location/URL, or it defaults to a app logo.

func GetOne

func GetOne[T any](cache *core.Cache, key string, model T) (T, bool)

GetOne fetches just one very item from the given cache instance. As long as the function is generic, the type is asserted automatically, so the type passing is required. Returns the requested item and the its retrieval result as boolean.

func LoadAll

func LoadAll() string

func Lock added in v0.43.2

func Lock()

Lock function ensures that the database driver is set to the readonly (RO) mode.

func MarkLoaded added in v0.44.18

func MarkLoaded()

MarkLoaded function unlock the database(s) state for the assiciated metrics updating. This means that the database has been loaded on start.

func Router

func Router() chi.Router

func RunMigrations

func RunMigrations(l common.LoggerInterface) string

RunMigrations is a wrapper function for the migration registration and execution.

func SetOne

func SetOne[T any](cache *core.Cache, key string, model T) bool

SetOne writes the input value of some type to the corresponding cache storing the very same item type (TODO ensure this). Fails if the database state is locked or uninitialized.

func Unlock added in v0.43.2

func Unlock()

Unlock function ensures that the database driver is set to the readwrite (RW) mode.

Types

This section is empty.

Jump to

Keyboard shortcuts

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