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 ¶
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 ¶
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 ¶
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) Read ¶
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 ¶
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.
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.