custom

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DebugMode = false

Functions

This section is empty.

Types

type Database

type Database struct {
	File       *os.File
	Path       string
	BitSize    uint16
	PrefixList []byte
	MU         sync.Mutex
	// contains filtered or unexported fields
}

func Open

func Open(path string, encKey []byte, bitSize uint16, prefixList []byte) (*Database, error)

Open opens an existing database or creates a new one

@bitSize tells the database what bit size to use (this value must always be consistent)

  • (default: 128)
  • (0 = default 128)
  • (min = 64)
  • (max = 64000)

note: in debug mode, (min = 16)

@prefixList tells the database what additional characters to preserve for the database object prefixes

func (*Database) Close

func (db *Database) Close() error

Close closes the database file

type Object

type Object struct {
	Key  []byte
	Val  []byte
	Line int64

	OldKey []byte
	OldVal []byte
}

func AddDataObj

func AddDataObj(db *Database, prefix byte, key []byte, val []byte) (Object, error)

AddDataObj adds a new key value pair to the database, given a prefix

note: this method also runs `File.Seek(0, io.SeekStart)`

func DelDataObj

func DelDataObj(db *Database, prefix byte) (Object, error)

DelDataObj removes a key value pair from the database, given a prefix

func GetDataObj

func GetDataObj(db *Database, prefix byte, key []byte, val []byte, stopAfterFirstRow ...bool) (Object, error)

GetDataObj finds a key value pair in the database, given a prefix

set the first byte of the key/val param to 0 to authorize the use of regex

func SetDataObj

func SetDataObj(db *Database, prefix byte, key []byte, val []byte) (Object, error)

SetDataObj replaces an old key value pair with a new one

note: it is your job to run the `File.Seek` method, and start at the correct position

Jump to

Keyboard shortcuts

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