stores

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package stores provides key/value stores for LLM applications, mirroring langchain_core.stores.

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyNotFound = errors.New("key not found")

ErrKeyNotFound is returned when a key is missing from a store.

Functions

This section is empty.

Types

type InMemoryByteStore

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

InMemoryByteStore stores arbitrary values as JSON bytes, mirroring langchain_core.stores.InMemoryByteStore.

func NewInMemoryByteStore

func NewInMemoryByteStore() *InMemoryByteStore

NewInMemoryByteStore returns an empty InMemoryByteStore.

func (*InMemoryByteStore) MDelete

func (s *InMemoryByteStore) MDelete(ctx context.Context, keys []string) error

MDelete removes the given keys.

func (*InMemoryByteStore) MGet

func (s *InMemoryByteStore) MGet(ctx context.Context, keys []string) ([][]byte, []bool, error)

MGet returns the raw bytes for the given keys.

func (*InMemoryByteStore) MSet

func (s *InMemoryByteStore) MSet(ctx context.Context, pairs map[string][]byte) error

MSet stores the given key/value pairs.

func (*InMemoryByteStore) YieldKeys

func (s *InMemoryByteStore) YieldKeys(ctx context.Context, prefix string) ([]string, error)

YieldKeys returns keys matching the prefix.

type InMemoryStore

type InMemoryStore[K comparable, V any] struct {
	// contains filtered or unexported fields
}

InMemoryStore is an in-memory Store implementation, mirroring langchain_core.stores.InMemoryStore.

func NewInMemoryStore

func NewInMemoryStore[K comparable, V any]() *InMemoryStore[K, V]

NewInMemoryStore returns an empty InMemoryStore.

func (*InMemoryStore[K, V]) MDelete

func (s *InMemoryStore[K, V]) MDelete(ctx context.Context, keys []K) error

MDelete implements Store.

func (*InMemoryStore[K, V]) MGet

func (s *InMemoryStore[K, V]) MGet(ctx context.Context, keys []K) ([]V, []bool, error)

MGet implements Store.

func (*InMemoryStore[K, V]) MSet

func (s *InMemoryStore[K, V]) MSet(ctx context.Context, pairs map[K]V) error

MSet implements Store.

func (*InMemoryStore[K, V]) YieldKeys

func (s *InMemoryStore[K, V]) YieldKeys(ctx context.Context, prefix string) ([]K, error)

YieldKeys implements Store.

type JSONCodec

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

JSONCodec allows storing arbitrary (JSON-serializable) values in a byte store.

func NewJSONCodec

func NewJSONCodec(store *InMemoryByteStore) *JSONCodec

NewJSONCodec wraps a byte store with JSON (de)serialization.

func (*JSONCodec) MGet

func (c *JSONCodec) MGet(ctx context.Context, keys []string) ([]any, []bool, error)

MGet decodes the stored bytes into values.

func (*JSONCodec) MSet

func (c *JSONCodec) MSet(ctx context.Context, pairs map[string]any) error

MSet encodes and stores the values.

type Store

type Store[K comparable, V any] interface {
	// MGet returns the values for the given keys, preserving order. Missing keys
	// yield their zero value and a false flag.
	MGet(ctx context.Context, keys []K) ([]V, []bool, error)
	// MSet sets the values for the given key/value pairs.
	MSet(ctx context.Context, pairs map[K]V) error
	// MDelete removes the given keys.
	MDelete(ctx context.Context, keys []K) error
	// YieldKeys iterates over keys matching the given prefix.
	YieldKeys(ctx context.Context, prefix string) ([]K, error)
}

Store is a generic key/value store interface, mirroring langchain_core.stores.BaseStore.

Jump to

Keyboard shortcuts

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