Documentation
¶
Overview ¶
Filesystem-backed key-value storage.
In-memory key-value storage for tests and temporary use.
SQLite key-value storage using the pure-Go liustack/sqlite driver.
Package storage provides Storage Domain KV abstractions, matching core/storage-domain. Backend supplies versioned Get/Put/Delete/List with file, SQLite, and memory implementations. Domain[T] serializes typed values and exposes consistent CAS semantics: writes supply an expected version and conflicts return ErrCASMismatch. Feedback, goal views, session sidecars, skill catalogs, and workspace registries share this typed persistence layer.
Index ¶
- func IsCASMismatch(err error) bool
- func IsKeyNotFound(err error) bool
- func Migrate(ctx context.Context, src, dst Backend) (migrated int, skipped []string, err error)
- type Backend
- type Domain
- func (d *Domain[T]) Delete(ctx context.Context, key string) error
- func (d *Domain[T]) Get(ctx context.Context, key string) (T, uint64, error)
- func (d *Domain[T]) List(ctx context.Context) ([]string, error)
- func (d *Domain[T]) Put(ctx context.Context, key string, value T, expectedVersion uint64) (uint64, error)
- type ErrCASMismatch
- type ErrKeyNotFound
- type FileKV
- func (f *FileKV) Delete(ctx context.Context, key string) error
- func (f *FileKV) Get(ctx context.Context, key string) ([]byte, uint64, error)
- func (f *FileKV) List(ctx context.Context, prefix string) ([]string, error)
- func (f *FileKV) Put(ctx context.Context, key string, data []byte, expectedVersion uint64) (uint64, error)
- type MemoryKV
- func (m *MemoryKV) Delete(ctx context.Context, key string) error
- func (m *MemoryKV) Get(ctx context.Context, key string) ([]byte, uint64, error)
- func (m *MemoryKV) List(ctx context.Context, prefix string) ([]string, error)
- func (m *MemoryKV) Put(ctx context.Context, key string, data []byte, expectedVersion uint64) (uint64, error)
- type SQLiteKV
- func (s *SQLiteKV) Close() error
- func (s *SQLiteKV) Delete(ctx context.Context, key string) error
- func (s *SQLiteKV) Get(ctx context.Context, key string) ([]byte, uint64, error)
- func (s *SQLiteKV) List(ctx context.Context, prefix string) ([]string, error)
- func (s *SQLiteKV) Put(ctx context.Context, key string, data []byte, expectedVersion uint64) (uint64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCASMismatch ¶
IsCASMismatch identifies CAS version conflicts.
func IsKeyNotFound ¶
IsKeyNotFound identifies missing-key errors.
Types ¶
type Backend ¶
type Backend interface {
// Get returns data and version, or ErrKeyNotFound.
Get(ctx context.Context, key string) (data []byte, version uint64, err error)
// Put writes with CAS; expectedVersion=0 requests creation.
Put(ctx context.Context, key string, data []byte, expectedVersion uint64) (version uint64, err error)
// Delete removes a key; missing keys are not errors.
Delete(ctx context.Context, key string) error
// List returns keys beneath a prefix with that prefix removed.
List(ctx context.Context, prefix string) (keys []string, err error)
}
Backend provides versioned key-value storage. Creation expects version zero and produces version one. Other Put calls must match the current version or return *ErrCASMismatch.
type Domain ¶
type Domain[T any] struct { // contains filtered or unexported fields }
Domain provides typed storage with a common prefix to prevent cross-domain collisions.
type ErrCASMismatch ¶
ErrCASMismatch indicates that an expected write version differs from the stored version.
type ErrKeyNotFound ¶
type ErrKeyNotFound struct {
Key string
}
ErrKeyNotFound indicates a missing key.
type FileKV ¶
type FileKV struct {
// contains filtered or unexported fields
}
FileKV implements Backend with files at <root>/<key> containing {"version":N,"data":"<base64>"}.
type MemoryKV ¶
type MemoryKV struct {
// contains filtered or unexported fields
}
MemoryKV implements Backend with an in-memory map.
type SQLiteKV ¶
type SQLiteKV struct {
// contains filtered or unexported fields
}
SQLiteKV implements Backend using kv(key TEXT PRIMARY KEY, version INTEGER, data BLOB).
func NewSQLiteKV ¶
NewSQLiteKV opens or creates a database and initializes its table.