db

package
v0.0.0-...-df9eb53 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// KV is the key-value database used to store ZIP->co-ordinate mappings.
	KV *bolt.DB

	// Bkt is the default Bolt KV DB bucket.
	Bkt []byte

	// Path is the location of KV database.
	Path string
}

DB represents the key-value database and assoicated items.

func NewDB

func NewDB() *DB

NewDB creates a new database.

func (*DB) Cleanup

func (db *DB) Cleanup()

Cleanup closes and removes the database.

func (*DB) Dump

func (db *DB) Dump(dumper func(k, v []byte))

Dump pretty-prints all database entries.

func (*DB) Init

func (db *DB) Init(path string) error

Init opens a database at the given path and intialises it.

func (*DB) Insert

func (db *DB) Insert(key, value []byte) error

Insert adds a new entry to the database.

func (*DB) Lookup

func (db *DB) Lookup(key []byte) ([]byte, error)

Lookup reutrns an entry from database for given ZIP.

func (*DB) Remove

func (db *DB) Remove(key []byte) error

Remove deletes an entry for the given ZIP-code from the database.

Jump to

Keyboard shortcuts

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