storage

package
v0.0.0-...-0469982 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupFolders

func SetupFolders()

SetupFolders ensures that required application directories exist.

Types

type Identifiable

type Identifiable interface {
	GetID() string
}

Identifiable is an interface for types that have a unique identifier.

type Storage

type Storage[T Identifiable] interface {
	Get(ctx context.Context, id string) (T, error)
	Set(ctx context.Context, item T) error
	Keys(ctx context.Context) iter.Seq[string]
	Delete(ctx context.Context, item T) (bool, error)
}

Storage is a generic interface for storing and retrieving identifiable items.

type StorageProvider

type StorageProvider[T Identifiable] interface {
	AppStorage() (Storage[T], error)
	UserStorage() (Storage[T], error)
	StateStorage() (Storage[T], error)
}

StorageProvider provides access to different storage locations.

func DBStorage

func DBStorage[T Identifiable](db *persistence.DB) StorageProvider[T]

DBStorage creates a database-based storage provider for the given type.

func FileStorage

func FileStorage[T Identifiable]() StorageProvider[T]

FileStorage creates a file-based storage provider for the given type.

Jump to

Keyboard shortcuts

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