badger

package
v0.0.46 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package badger provides a wrapper functions for Badger database interactions.

REQUIRED VARIABLES: (SET ON INIT)

DataDir       string
OptionsDir    string
TimeZone      string
LogPrefix     string
EncryptionKey string

Example:

func badgerInit() {
	c.Get(globals.ConfigFile)
	badger.DataDir = c.Badger.DataDir
	badger.OptionsDir = c.Badger.OptionsDir
	badger.TimeZone = c.TimeZone
	badger.LogPrefix = c.LogPrefix
	badger.EncryptionKey = globals.EncryptionKey
	badger.EncryptionIV = globals.EncryptionIV
}

Index

Constants

This section is empty.

Variables

View Source
var (

	// Set on init
	DataDir       string
	OptionsDir    string
	TimeZone      string
	LogPrefix     string
	EncryptionKey []byte
)

Functions

func DBConnectionInit

func DBConnectionInit() error

Types

type Command

type Command struct {
	Key   []byte
	Value []byte
}

type CommandsRepository

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

func GetDB

func GetDB() *CommandsRepository

func NewCommandsRepository

func NewCommandsRepository(dbPath string) (*CommandsRepository, error)

func (*CommandsRepository) Close

func (b *CommandsRepository) Close() error

func (*CommandsRepository) Delete

func (b *CommandsRepository) Delete(k []byte) error

func (*CommandsRepository) Get

func (b *CommandsRepository) Get(k []byte) ([]byte, error)

func (*CommandsRepository) GetAll

func (b *CommandsRepository) GetAll() ([]Command, error)

func (*CommandsRepository) Iterate

func (b *CommandsRepository) Iterate(prefix []byte) ([]Command, error)

func (*CommandsRepository) Set

func (b *CommandsRepository) Set(k, v []byte) error

type Repository

type Repository interface {
	GetAll() ([]Command, error)
	Get(key []byte) ([]byte, error)
	Set(key []byte, value []byte) error
	Delete(key []byte) error
	Iterate(key []byte) ([]Command, error)
}

Jump to

Keyboard shortcuts

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