memstore

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Overview

Package memstore implements the blob.Store and blob.KV interfaces using in-memory dictionaries. This is primarily useful for testing, as the contents are not persisted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Opener

func Opener(_ context.Context, _ string) (blob.StoreCloser, error)

Opener constructs a blob.StoreCloser for use with the store package. The concrete type of the result is memstore.Store. The address is ignored, and an error is never returned.

Types

type KV added in v0.7.0

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

KV implements the blob.KV interface using an in-memory dictionary. The contents of a Store are not persisted. All operations on a memstore are safe for concurrent use by multiple goroutines.

func NewKV added in v0.8.0

func NewKV() *KV

NewKV constructs a new, empty key-value namespace.

func (*KV) Clear added in v0.7.0

func (s *KV) Clear()

Clear removes all keys and values from s.

func (*KV) Delete added in v0.7.0

func (s *KV) Delete(_ context.Context, key string) error

Delete implements part of blob.KV.

func (*KV) Get added in v0.7.0

func (s *KV) Get(_ context.Context, key string) ([]byte, error)

Get implements part of blob.KV.

func (*KV) Init added in v0.7.0

func (s *KV) Init(m map[string]string) *KV

Init replaces the contents of s with the keys and values in m. It returns s to permit chaining with construction.

func (*KV) Len added in v0.7.0

func (s *KV) Len(context.Context) (int64, error)

Len implements part of blob.KV.

func (*KV) List added in v0.7.0

func (s *KV) List(_ context.Context, start string, f func(string) error) error

List implements part of blob.KV.

func (*KV) Put added in v0.7.0

func (s *KV) Put(_ context.Context, opts blob.PutOptions) error

Put implements part of blob.KV.

func (*KV) Size added in v0.7.0

func (s *KV) Size(_ context.Context, key string) (int64, error)

Size implements part of blob.KV.

func (*KV) Snapshot added in v0.7.0

func (s *KV) Snapshot(m map[string]string) map[string]string

Snapshot copies a snapshot of the keys and values of s into m. If m == nil, a new empty map is allocated and returned. It returns m to allow chaining with construction.

type Store

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

A Store implements the blob.Store interface using an in-memory dictionary for each keyspace. A zero value is ready for use, but must not be copied after its first use.

func New

func New(newKV func() blob.KV) *Store

New constructs a new empty Store that uses newKV to construct keyspaces. If newKV == nil, NewKV is used.

func (*Store) CAS added in v0.9.0

func (s *Store) CAS(ctx context.Context, name string) (blob.CAS, error)

CAS implements part of blob.Store. This implementation never reports an error.

func (*Store) Close

func (*Store) Close(context.Context) error

Close implements part of blob.StoreCloser. This implementation is a no-op.

func (*Store) KV added in v0.9.0

func (s *Store) KV(_ context.Context, name string) (blob.KV, error)

KV implements part of blob.Store. This implementation never reports an error.

func (*Store) Sub added in v0.8.0

func (s *Store) Sub(_ context.Context, name string) (blob.Store, error)

Sub implements part of blob.Store. This implementation never reports an error.

Jump to

Keyboard shortcuts

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