Help us shape the future of Go! Take the 2026 Go Developer Survey

inmemory

package
v1.152.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package inmemory provides a process-local database.Database for platforms where sqlite is unavailable (js/wasm). It follows the sqlite implementation: insertion order, AND keyword search, and the same sentinel errors. Contents are lost when the process exits.

Case folding is not identical: sqlite's LOWER() only folds ASCII, whereas this package uses Go's Unicode-aware folding, so non-ASCII queries may match here and not in sqlite.

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateID = errors.New("memory ID already exists")

Functions

This section is empty.

Types

type Database

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

func New

func New() *Database

func (*Database) AddMemory

func (d *Database) AddMemory(ctx context.Context, memory database.UserMemory) error

func (*Database) DeleteMemory

func (d *Database) DeleteMemory(ctx context.Context, memory database.UserMemory) error

func (*Database) GetMemories

func (d *Database) GetMemories(ctx context.Context) ([]database.UserMemory, error)

func (*Database) SearchMemories

func (d *Database) SearchMemories(ctx context.Context, query, category string) ([]database.UserMemory, error)

SearchMemories returns memories whose content contains every whitespace separated word of query and whose category equals category, both compared case-insensitively (Unicode folding, see package doc). Empty query or category disables that filter. Like the sqlite implementation, it returns a nil slice when nothing matches.

func (*Database) UpdateMemory

func (d *Database) UpdateMemory(ctx context.Context, memory database.UserMemory) error

Jump to

Keyboard shortcuts

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