memstore

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Overview

Package memstore implements the blob.Store interface using a map.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Opener

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

Opener constructs a memstore, for use with the store package. The address is ignored, and an error will never be returned.

Types

type Store

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

Store implements the blob.Store 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 New

func New() *Store

New constructs a new, empty store.

func (*Store) Clear

func (s *Store) Clear()

Clear removes all keys and values from s.

func (*Store) Close

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

Close implements part of blob.Store. It is a no-op here.

func (*Store) Delete

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

Delete implements part of blob.Store.

func (*Store) Get

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

Get implements part of blob.Store.

func (*Store) Init added in v0.4.0

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

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

func (*Store) Len

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

Len implements part of blob.Store.

func (*Store) List

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

List implements part of blob.Store.

func (*Store) Put

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

Put implements part of blob.Store.

func (*Store) Size

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

Size implements part of blob.Store.

func (*Store) Snapshot

func (s *Store) 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.

Jump to

Keyboard shortcuts

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