engine

package
v0.0.0-...-723cda8 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2025 License: GPL-3.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NabiaDB

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

func LoadFromFile

func LoadFromFile(filename string) (*NabiaDB, error)

LoadFromFile loads a NabiaDB from a file. It uses the gob package for deserialization. The function returns a pointer to the NabiaDB and an error if the file reading or decoding fails.

func NewNabiaDB

func NewNabiaDB(location string) (*NabiaDB, error)

NewNabiaDB is the constructor for NabiaDB. It takes a location string and returns a pointer to a NabiaDB and a (nullable) error.

func (*NabiaDB) Delete

func (ns *NabiaDB) Delete(key string)

Delete takes a key and removes it from the map. This method doesn't have existence-checking logic. It is safe to use on empty data, it simply doesn't do anything if the record doesn't exist. -1 size if the key exists. +1 write.

func (*NabiaDB) Exists

func (ns *NabiaDB) Exists(key string) bool

func (*NabiaDB) Read

func (ns *NabiaDB) Read(key string) ([]byte, error)

Read takes a key name and attempts to pull the data from the Nabia DB map. Returns a NabiaRecord if found and an error if not found. Callers must always check the error returned in the second parameter, as the result cannot be used if the "error" field is not nil. This function is safe to call even with empty data, because the method applies a mutex. +1 read.

func (*NabiaDB) SaveToFile

func (ns *NabiaDB) SaveToFile(filename string) error

SaveToFile saves the NabiaDB to a file. It uses the gob package for serialization. The file is truncated if it already exists. The function returns an error if the file creation or encoding fails.

func (*NabiaDB) Stop

func (ns *NabiaDB) Stop()

func (*NabiaDB) Write

func (ns *NabiaDB) Write(key string, value []byte) error

Write takes the key and a value of NabiaRecord datatype and places it on the database, potentially overwriting whatever was there before, because Write has no data safety features preventing the overwriting of data. +1 write when validation passes. +1 size if the key is new.

type NabiaRecord

type NabiaRecord struct {
	RawData []byte
}

NabiaRecord represents the value in the key-value pair in the Nabia database. The value is a byte slice, which can be any data type, using serialization.

func NewNabiaRecord

func NewNabiaRecord(data []byte) (*NabiaRecord, error)

NewNabiaRecord is the constructor for NabiaRecord. It takes a byte slice and returns a pointer to a NabiaRecord and an error.

Jump to

Keyboard shortcuts

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