cache

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Buckets
	PAGE_DATA    = "PageData"
	CALENDAR     = "Calendar"
	USER_DATA    = "UserData"
	LEADERBOARDS = "Leaderboards"
	PUZZLES      = "Puzzles"

	// Sub Buckets
	USER_INPUTS = "UserInputs"
	USER_PAGES  = "UserPages"

	// Other
	GENERIC_USER = "GenericUser"
)

Variables

View Source
var (
	UserCacheDir, _ = os.UserCacheDir()
	CacheDir        = path.Join(UserCacheDir, "aocgo")
	CacheFile       = path.Join(CacheDir, "%v.db")
	InputCacheDir   = path.Join(CacheDir, "inputs")
	GeneralCacheDB  = fmt.Sprintf(CacheFile, GENERIC_USER)
)

Functions

func ClearUserDatabase

func ClearUserDatabase(sessionToken string)

Clear database file for a certain user

func LoadResource

func LoadResource(bucketName, idToLoad string) []byte

Load resource from database by ID

func SaveGenericResource

func SaveGenericResource(bucketName, idToSave string, dataToSave []byte)

Save resource to database

func SaveResource

func SaveResource(r Resource)

func ShutdownDBM

func ShutdownDBM()

Ensure Master DBM gets shutdown

func StartupDBM

func StartupDBM(userSession string) error

Create and initialize master database manager, taking in a valid AoC user session token

Types

type DatabaseManager

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

Database Manager

func (*DatabaseManager) Shutdown

func (dbm *DatabaseManager) Shutdown()

Ensure database is properly closed

type Resource

type Resource interface {
	GetID() string                // ID is used as key for storage
	GetBucketName() string        // Returns the name of the bucket the resource is stored in
	MarshalData() ([]byte, error) // Returns the resources data in a savable format
	SaveResource()
}

Interface for storable resource

Jump to

Keyboard shortcuts

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