gomemdb

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Info

func Info() (string, string)

returns gomemdb version and it's license

Types

type GoMemDb

type GoMemDb struct {
	Filename          string
	KeyPairs          []KeyPair
	Compress          bool
	ZlibCompressLevel int
}

GoMemoryDatabase structure. Filename is name of file where to write db. KeyPairs are values. Compress. Set it to true if you want zlib compression.

func NewDb

func NewDb(filename string) GoMemDb

creates database instance

func Open

func Open(filename string, compressed bool) (GoMemDb, error)

opens saved db state to file and returns it

func (*GoMemDb) Add

func (gmdb *GoMemDb) Add(key string, pair interface{}) error

adds to keypairs new value

func (*GoMemDb) Clear added in v0.2.0

func (gmdb *GoMemDb) Clear()

clears keypair slice

func (*GoMemDb) Delete

func (gmdb *GoMemDb) Delete(key string) error

deletes key pair

func (*GoMemDb) Get

func (gmdb *GoMemDb) Get(key string) interface{}

finds value by key

func (*GoMemDb) GroupByPairDatatype added in v0.2.0

func (gmdb *GoMemDb) GroupByPairDatatype(datatype interface{}) map[string]interface{}

returns map with keys and values based on given datatype

func (*GoMemDb) NeedCompress

func (gmdb *GoMemDb) NeedCompress()

sets Compress to true

func (*GoMemDb) Representate

func (gmdb *GoMemDb) Representate() map[string]interface{}

returns map representation of all keypairs

func (*GoMemDb) Save

func (gmdb *GoMemDb) Save() error

saves db state to file

func (*GoMemDb) Set

func (gmdb *GoMemDb) Set(key string, value interface{}) error

sets new value for key

type KeyPair

type KeyPair struct {
	Key  string
	Pair interface{}
}

key pair struct

func NewKP

func NewKP(key string, pair interface{}) KeyPair

function to create KeyPair

Jump to

Keyboard shortcuts

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