persistence

package
v1.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package persistence provides SQLite-based persistence for MCP cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheMetadata

type CacheMetadata struct {
	Hash      string    `json:"hash"`
	FilePath  string    `json:"file_path"`
	Timestamp time.Time `json:"timestamp"`
	Accessed  time.Time `json:"accessed"`
	HitCount  int       `json:"hit_count"`
	Size      int64     `json:"size"`
}

CacheMetadata represents persisted cache entry metadata (without content).

type Store

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

Store provides SQLite-backed persistence for cache metadata.

func NewStore

func NewStore(dbPath string) (*Store, error)

NewStore creates a new SQLite-backed store.

func (*Store) Backup

func (s *Store) Backup(backupPath string) error

Backup creates a backup of the store to a JSON file.

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection.

func (*Store) DeleteMetadata

func (s *Store) DeleteMetadata(hash string) error

DeleteMetadata removes metadata by hash.

func (*Store) DeleteOlderThan

func (s *Store) DeleteOlderThan(d time.Duration) (int64, error)

DeleteOlderThan removes entries older than the given duration.

func (*Store) GetMetadata

func (s *Store) GetMetadata(hash string) (*CacheMetadata, error)

GetMetadata retrieves metadata by hash.

func (*Store) GetStats

func (s *Store) GetStats() (totalEntries, totalSize int64, oldest, newest time.Time, err error)

GetStats returns store statistics.

func (*Store) GetStoreMetadata

func (s *Store) GetStoreMetadata(key string) (string, error)

GetStoreMetadata retrieves a metadata value.

func (*Store) LoadAllMetadata

func (s *Store) LoadAllMetadata() ([]*CacheMetadata, error)

LoadAllMetadata loads all cached metadata entries.

func (*Store) Restore

func (s *Store) Restore(backupPath string) error

Restore restores the store from a JSON backup.

func (*Store) SaveMetadata

func (s *Store) SaveMetadata(meta *CacheMetadata) error

SaveMetadata saves cache entry metadata.

func (*Store) SetStoreMetadata

func (s *Store) SetStoreMetadata(key, value string) error

SetStoreMetadata sets a metadata value.

func (*Store) Vacuum

func (s *Store) Vacuum() error

Vacuum runs SQLite VACUUM to reclaim space.

Jump to

Keyboard shortcuts

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