memorystore

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryStore

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

MemoryStore is an in-memory implementation for managing and storing histories. It uses a map to associate aggregate IDs with their corresponding histories, and a mutex to ensure thread-safe operations.

func New

func New(snapshotInterval int32) *MemoryStore

New initializes and returns a new instance of MemoryStore. Pass the aggregate's snapshot interval (0 to disable snapshots).

func (*MemoryStore) Load

func (m *MemoryStore) Load(ctx context.Context, aggregateId string) (*historyv1.History, error)

Load retrieves the history for a given aggregate ID. If the context is canceled or timed out, it returns an error. The function uses read locks for thread-safe read access to the `events` map.

func (*MemoryStore) Save

func (m *MemoryStore) Save(ctx context.Context, aggregateId string, records ...*recordv1.Record) error

Save stores a list of records for a given aggregate ID. If the context is canceled or timed out, it returns an error. The function uses write locks for thread-safe access to the `events` map.

func (*MemoryStore) SnapshotInterval

func (m *MemoryStore) SnapshotInterval() int32

SnapshotInterval returns the snapshot interval (0 means disabled).

Jump to

Keyboard shortcuts

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