database

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package database is for a local storage layer for the application

Index

Constants

This section is empty.

Variables

View Source
var ErrDatabaseNotConnected = errors.New("database is not connected")

ErrDatabaseNotConnected is returned when the database is not connected

Functions

This section is empty.

Types

type DB

type DB struct {
	Connected bool
	// contains filtered or unexported fields
}

DB is the database struct

func Connect

func Connect(folder, database string) (db *DB, err error)

Connect will make a new database connection and new folder/file(s) if needed

func (*DB) Disconnect

func (db *DB) Disconnect() error

Disconnect will close the db connection

func (*DB) Flush

func (db *DB) Flush() error

Flush will empty the entire database

func (*DB) GarbageCollection

func (db *DB) GarbageCollection() (err error)

GarbageCollection will clean up some garbage in the database (reduces space, etc.)

func (*DB) Get

func (db *DB) Get(key string) (string, error)

Get will retrieve a value from a key (if found)

func (*DB) Set

func (db *DB) Set(key, value string, ttl time.Duration) error

Set will store a new key/value pair (expiration optional)

Jump to

Keyboard shortcuts

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