arkmem

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package arkmem implements ark.Backend in memory.

Objects live in a map keyed by "<namespace>/<name>", where the namespace is ark.HandleType.String(). Nothing is persisted; a Backend starts empty and is discarded with its process. It exists for unit tests and examples that need a repository without a filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

Backend implements ark.Backend backed by a map. It is safe for concurrent use; the zero value is not, use New.

func New

func New() *Backend

New creates an empty in-memory backend.

func (*Backend) Close

func (b *Backend) Close() error

Close drops every stored object. The backend stays usable and is empty afterwards.

func (*Backend) Delete

func (b *Backend) Delete(ctx context.Context, h ark.Handle) error

Delete removes the object identified by h. A missing object is not an error.

func (*Backend) Exists

func (b *Backend) Exists(ctx context.Context, h ark.Handle) (bool, error)

Exists reports whether the object identified by h is present.

func (*Backend) Get

func (b *Backend) Get(ctx context.Context, h ark.Handle) (io.ReadCloser, error)

Get returns a reader over a copy of the object stored under h.

func (*Backend) List

func (b *Backend) List(ctx context.Context, t ark.HandleType, fn func(ark.BlobInfo) error) error

List calls fn for every object in the namespace of t. An empty namespace is not an error.

func (*Backend) Put

func (b *Backend) Put(ctx context.Context, h ark.Handle, r io.Reader) error

Put reads r fully and stores it under h, replacing any existing object. The store is only updated once the read succeeded, so a failed Put leaves the previous object in place and no reader observes a partial one.

func (*Backend) Stat

func (b *Backend) Stat(ctx context.Context, h ark.Handle) (ark.BlobInfo, error)

Stat returns metadata for the object stored under h.

func (*Backend) Sync added in v0.2.0

func (b *Backend) Sync(ctx context.Context) error

Sync is a no-op: memory has no stable storage to reach.

Jump to

Keyboard shortcuts

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