inmem

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PutDisabledError    = errors.New("put operations disabled in inmem backend")
	GetDisabledError    = errors.New("get operations disabled in inmem backend")
	DeleteDisabledError = errors.New("delete operations disabled in inmem backend")
	ListDisabledError   = errors.New("list operations disabled in inmem backend")
)

Functions

func NewInmem

func NewInmem(_ map[string]string, logger log.Logger) (physical.Backend, error)

NewInmem constructs a new in-memory backend

func NewTransactionalInmem

func NewTransactionalInmem(_ map[string]string, logger log.Logger) (physical.Backend, error)

Basically for now just creates a permit pool of size 1 so only one operation can run at a time

Types

type IBackend

type IBackend struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

InmemBackend is an in-memory only physical backend. It is useful for testing and development situations where the data is not expected to be durable.

func (*IBackend) Delete

func (i *IBackend) Delete(ctx context.Context, key string) error

Delete is used to permanently delete an entry

func (*IBackend) DeleteInternal

func (i *IBackend) DeleteInternal(ctx context.Context, key string) error

func (*IBackend) FailDelete

func (i *IBackend) FailDelete(fail bool)

func (*IBackend) FailGet

func (i *IBackend) FailGet(fail bool)

func (*IBackend) FailList

func (i *IBackend) FailList(fail bool)

func (*IBackend) FailPut

func (i *IBackend) FailPut(fail bool)

func (*IBackend) Get

func (i *IBackend) Get(ctx context.Context, key string) (*physical.Entry, error)

Get is used to fetch an entry

func (*IBackend) GetInternal

func (i *IBackend) GetInternal(ctx context.Context, key string) (*physical.Entry, error)

func (*IBackend) List

func (i *IBackend) List(ctx context.Context, prefix string) ([]string, error)

List is used to list all the keys under a given prefix, up to the next prefix.

func (*IBackend) ListInternal

func (i *IBackend) ListInternal(ctx context.Context, prefix string) ([]string, error)

func (*IBackend) Put

func (i *IBackend) Put(ctx context.Context, entry *physical.Entry) error

Put is used to insert or update an entry

func (*IBackend) PutInternal

func (i *IBackend) PutInternal(ctx context.Context, entry *physical.Entry) error

type TransactionalInmemBackend

type TransactionalInmemBackend struct {
	IBackend
}

func (*TransactionalInmemBackend) Transaction

func (t *TransactionalInmemBackend) Transaction(ctx context.Context, txns []*physical.TxnEntry) error

Implements the transaction interface

Jump to

Keyboard shortcuts

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