database

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package database provides a SQLite-backed key-value storage adapter.

pkg/adapter/storage/database/storage.go

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound indicates key was not found
	ErrNotFound = errors.New("key not found")
	// ErrInvalidKey indicates empty or malformed key
	ErrInvalidKey = errors.New("invalid key")
	// ErrConnection indicates database connection failure
	ErrConnection = errors.New("database connection error")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// DriverName is the database driver (e.g., "postgres", "mysql", "sqlite3")
	DriverName string
	// DSN is the data source name / connection string
	DSN string
	// TableName is the name of the storage table (default: "morpheus_storage")
	TableName string
	// MaxOpenConns is max open connections (default: 25)
	MaxOpenConns int
	// MaxIdleConns is max idle connections (default: 5)
	MaxIdleConns int
}

Config holds database configuration

type Storage

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

Storage provides database-backed persistence

func NewStorage

func NewStorage(cfg Config) (*Storage, error)

NewStorage creates a new database storage adapter

func (*Storage) Close

func (s *Storage) Close() error

Close closes the database connection

func (*Storage) Delete

func (s *Storage) Delete(ctx context.Context, key string) error

Delete removes data for the given key

func (*Storage) List

func (s *Storage) List(ctx context.Context, prefix string) ([]string, error)

List retrieves all keys with the given prefix

func (*Storage) Load

func (s *Storage) Load(ctx context.Context, key string) (any, error)

Load retrieves data for the given key

func (*Storage) Save

func (s *Storage) Save(ctx context.Context, key string, data any) error

Save persists data with the given key

Jump to

Keyboard shortcuts

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