memory

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableLogWrites

func DisableLogWrites()

func EnableLogWrites

func EnableLogWrites()

func NewBatch

func NewBatch(prefix string, get GetFunc, commit CommitFunc) storage.KeyValueTxn

Types

type Batch

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

func (*Batch) Begin

func (b *Batch) Begin(writable bool) storage.KeyValueTxn

func (*Batch) BeginWithPrefix

func (b *Batch) BeginWithPrefix(writable bool, prefix string) storage.KeyValueTxn

func (*Batch) Commit

func (b *Batch) Commit() error

func (*Batch) Copy

func (b *Batch) Copy() *Batch

func (*Batch) Discard

func (b *Batch) Discard()

func (*Batch) Get

func (b *Batch) Get(key storage.Key) (v []byte, err error)

func (*Batch) Put

func (b *Batch) Put(key storage.Key, value []byte) error

func (*Batch) PutAll

func (b *Batch) PutAll(values map[storage.Key][]byte) error

type CommitFunc

type CommitFunc func(map[PrefixedKey][]byte) error

type DB

type DB struct {
	DBOpen atomicBool
	// contains filtered or unexported fields
}

DB Implements a key value store in memory. Very basic, assumes no initial state for the database That must be handled by the caller, but see the notes on InitDB for future improvements.

func New

func New(logger storage.Logger) *DB

func NewDB

func NewDB() *DB

func (*DB) Begin

func (db *DB) Begin(writable bool) storage.KeyValueTxn

func (*DB) BeginWithPrefix

func (db *DB) BeginWithPrefix(writable bool, prefix string) storage.KeyValueTxn

func (*DB) Close

func (m *DB) Close() error

Close Nothing really to do but to clear the Entries map

func (*DB) Copy

func (m *DB) Copy() *DB

Copy Make a copy of the database; a useful function for testing

func (*DB) MarshalJSON

func (m *DB) MarshalJSON() ([]byte, error)

func (*DB) Ready

func (m *DB) Ready() bool

Ready Returns true if the database is open and ready to accept reads/writes

func (*DB) UnmarshalJSON

func (m *DB) UnmarshalJSON(b []byte) error

type GetFunc

type GetFunc func(string, storage.Key) ([]byte, error)

type PrefixedKey

type PrefixedKey struct {
	Prefix string
	Key    storage.Key
}

func (PrefixedKey) String

func (k PrefixedKey) String() string

Jump to

Keyboard shortcuts

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