eondb

package
v0.0.0-...-8e21be9 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PUT_ERR    = errors.New("Key is already in use")
	REMOVE_ERR = errors.New("Cannot remove an element that does not exist")
	EXIST_ERR  = errors.New("Element does not exist")
	GET_ERR    = errors.New("Could not get value from the memDB")
)
View Source
var (
	DB_ERR = errors.New("DB could not be loaded: ")
)

Functions

func NewDB

func NewDB(name string) *leveldb.DB

Create / open a DB with the given file name.

Types

type MemDb

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

A db only stored on the memory. Will be used for storing data that the hard disk doesnt need to store.

func NewMemDb

func NewMemDb() *MemDb

Creates and returns a new memDb.

func (*MemDb) Get

func (db *MemDb) Get(key []byte) ([]byte, error)

Gets data from the memDB based on the given key. Returns the data and any errors that occured.

func (*MemDb) Has

func (db *MemDb) Has(key []byte) bool

Checks if a key already exists. This func is public as it is protected with locks.

func (*MemDb) Put

func (db *MemDb) Put(key []byte, data []byte) error

Adds a key and data pair to the mempool, but will not overide if the key is already used. Returns any errors.

func (*MemDb) Remove

func (db *MemDb) Remove(key []byte) error

Deletes an element from the db. Gives an error if the key used does not exist in the db.

func (*MemDb) Set

func (db *MemDb) Set(key []byte, data []byte) error

Sets the value of a key and data pair. Ignores if the key is already used or not.

Jump to

Keyboard shortcuts

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