database

package
v0.2.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSnapshot

func BuildSnapshot(db *Database) ([]byte, error)

BuildSnapshot serializes the database state into a JSON array of objects with keys K and V and the key and value for each entry as respective values

Types

type Database

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

A Database is a key-value store

func Clone

func Clone(db *Database) *Database

Clone makes a new instance of a database from an existing one

func InstallSnapshot

func InstallSnapshot(data []byte) (*Database, error)

InstallSnapshot deserializes a JSON string (following the schema created by BuildSnapshot) and returns a populated Database

func NewDatabase

func NewDatabase() *Database

NewDatabase returns an initialized Database

func (*Database) Delete

func (d *Database) Delete(key string)

Delete removes a key and value from the store

func (*Database) Get

func (d *Database) Get(key string) string

Get retrieves the value for a key (empty string if key does not exist)

func (*Database) Set

func (d *Database) Set(key string, value string)

Set assigns a value to a key

Jump to

Keyboard shortcuts

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