kvdb

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2021 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Path     string
	ReadOnly bool
	ForceNew bool
}

Config provides configuration parameters for KeyValueDB.

type KeyValueDB

type KeyValueDB struct {
	Config
	// contains filtered or unexported fields
}

KeyValueDB is a key-value database which spaGO can use to efficiently store large data.

func NewDefaultKeyValueDB

func NewDefaultKeyValueDB(config Config) *KeyValueDB

NewDefaultKeyValueDB returns a new KeyValueDB.

func (*KeyValueDB) Close

func (m *KeyValueDB) Close() error

Close closes the underlying DB. It's crucial to call it to ensure all the pending updates make their way to disk.

func (*KeyValueDB) DropAll

func (m *KeyValueDB) DropAll() error

DropAll would drop all the data stored. Readings or writings performed during this operation may result in panics.

func (*KeyValueDB) Get

func (m *KeyValueDB) Get(key []byte) (value []byte, ok bool, err error)

Get returns the value associated to the given key, if it exists.

func (*KeyValueDB) Keys

func (m *KeyValueDB) Keys() ([]string, error)

Keys returns all the keys from the DB.

func (KeyValueDB) MarshalBinary added in v0.4.0

func (KeyValueDB) MarshalBinary() ([]byte, error)

MarshalBinary prevents KeyValueDB to be encoded to binary representation.

It never makes sense to encode/decode a KeyValueDB value, for example when used as a model parameter. So this method always returns nil, and no errors.

func (*KeyValueDB) Put

func (m *KeyValueDB) Put(key []byte, value []byte) error

Put sets a new key/value pair in the DB.

func (*KeyValueDB) UnmarshalBinary added in v0.4.0

func (*KeyValueDB) UnmarshalBinary([]byte) error

UnmarshalBinary prevents KeyValueDB to be decoded from binary representation.

It never makes sense to encode/decode a KeyValueDB value, for example when used as a model parameter. So this method always does not modify the receiver in any way, and never returns errors.

Jump to

Keyboard shortcuts

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