memstore

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package memstore is an in-memory implementation of store.Storage used for tests, demos, and embedded scenarios where durability is not required. It is fully thread-safe.

Index

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 an in-memory store.Storage. The zero value is NOT usable; call New() to construct one with initialized maps.

func New

func New() *Store

New returns a fresh, empty Store.

func (*Store) AppendReflog

func (s *Store) AppendReflog(_ context.Context, name string, e store.ReflogEntry) error

AppendReflog appends e to the named reflog.

func (*Store) CASRef

func (s *Store) CASRef(_ context.Context, name string, expected, next store.Hash) error

CASRef updates name iff its current value equals expected.

A zero expected hash means "create only if absent". A zero next hash is rejected (use DeleteRef instead).

func (*Store) Close

func (s *Store) Close() error

Close is a no-op for the memory store.

func (*Store) DeleteRef

func (s *Store) DeleteRef(_ context.Context, name string, expected store.Hash) error

DeleteRef removes name iff its current value equals expected.

func (*Store) GetObject

func (s *Store) GetObject(_ context.Context, h store.Hash) (store.Object, error)

GetObject returns the object stored under h, or store.ErrNotFound.

func (*Store) GetRef

func (s *Store) GetRef(_ context.Context, name string) (store.Hash, bool, error)

GetRef returns the hash for name and whether it exists.

func (*Store) HasObject

func (s *Store) HasObject(_ context.Context, h store.Hash) (bool, error)

HasObject reports whether h is present.

func (*Store) IterObjects

func (s *Store) IterObjects(_ context.Context, fn func(store.Hash, store.Object) error) error

IterObjects calls fn for every (hash, object). Iteration order is deterministic (hash-ascending) for test reproducibility.

func (*Store) ListRefs

func (s *Store) ListRefs(_ context.Context, prefix string) ([]store.RefEntry, error)

ListRefs returns refs whose name has the given prefix, sorted by name.

func (*Store) PutObject

func (s *Store) PutObject(_ context.Context, h store.Hash, obj store.Object) error

PutObject stores obj under h. Re-puts of an existing hash are accepted silently (the bytes are guaranteed identical by the CAS property of content addressing).

func (*Store) ReadReflog

func (s *Store) ReadReflog(_ context.Context, name string) ([]store.ReflogEntry, error)

ReadReflog returns a copy of the reflog entries for name.

Jump to

Keyboard shortcuts

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