inmemory

package
v0.43.0 Latest Latest
Warning

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

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

Documentation

Overview

Package inmemory provides the in-process reference history store. Its zero value is ready to use: see Store.

Example
package main

import (
	"context"
	"fmt"

	"github.com/Tangerg/scope/core/chat"
	"github.com/Tangerg/scope/core/history"
	"github.com/Tangerg/scope/core/history/inmemory"
)

func main() {
	ctx := context.Background()
	store := new(inmemory.Store)
	message := chat.NewUserMessage(chat.NewTextPart("hello"))
	if _, err := store.Write(ctx, history.ConversationID("demo"), message); err != nil {
		panic(err)
	}
	messages, err := store.Read(ctx, history.ConversationID("demo"))
	if err != nil {
		panic(err)
	}
	fmt.Println(len(messages), messages[0].Text())
}
Output:
1 hello

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store is a concurrency-safe in-process history store with a usable zero value. Writes snapshot inputs; reads return independently owned values. Missing conversations are empty, and all history is lost when the process exits.

func (*Store) Clear

func (s *Store) Clear(ctx context.Context, conversationID history.ConversationID) error

func (*Store) Conversations

func (s *Store) Conversations(ctx context.Context) ([]history.ConversationID, error)

func (*Store) Read

func (s *Store) Read(ctx context.Context, conversationID history.ConversationID) ([]chat.Message, error)

func (*Store) Write

func (s *Store) Write(ctx context.Context, conversationID history.ConversationID, messages ...chat.Message) (history.WriteOutcome, error)

Jump to

Keyboard shortcuts

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