storage

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SchemaVersion = 9
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB represents the database connection

func NewDB

func NewDB(cfg *config.Config) (*DB, error)

NewDB creates a new database connection

func (*DB) ApplyRetentionPolicy added in v0.4.0

func (db *DB) ApplyRetentionPolicy(policy RetentionPolicy) (int, error)

ApplyRetentionPolicy deletes old memories according to the retention policy

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection

func (*DB) GetConnection

func (db *DB) GetConnection() *sql.DB

GetConnection returns the underlying database connection

func (*DB) GetDatabaseStats added in v0.4.0

func (db *DB) GetDatabaseStats(dbPath string) (*DatabaseStats, error)

GetDatabaseStats returns statistics about the database

func (*DB) RunMaintenance added in v0.4.0

func (db *DB) RunMaintenance() error

RunMaintenance performs database optimization and cleanup

type DatabaseStats added in v0.4.0

type DatabaseStats struct {
	FileSizeBytes    int64
	TotalMemories    int
	MemoriesByType   map[string]int
	OldestMemoryTime string
	NewestMemoryTime string
	FragmentationPct float64
}

DatabaseStats holds statistics about the database

type RetentionPolicy added in v0.4.0

type RetentionPolicy struct {
	MaxAgeDays   int
	MaxCount     int
	ExcludeTypes []string
	DryRun       bool
}

RetentionPolicy defines rules for automatic memory cleanup

Jump to

Keyboard shortcuts

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