inmemory

package
v0.63.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 5 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 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"))
	batch, err := history.NewBatch("demo", "first-turn", message)
	if err != nil {
		panic(err)
	}
	if _, err = store.Append(ctx, batch); 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 holds messages, append receipts, and closed identities under one lock. Its zero value is usable. All records are lost when the process exits.

func (*Store) Append added in v0.60.0

func (s *Store) Append(ctx context.Context, batch history.Batch) (history.Receipt, error)

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)

Jump to

Keyboard shortcuts

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