badgerdb

package
v1.5.0-beta Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 7 Imported by: 0

README

BadgerDB

Package badgerdb provides a BadgerDB-backed implementation of the storage.Storage interface.

Usage

import "github.com/psyb0t/telegram-logger/internal/pkg/storage/badgerdb"

// Create a new badgerDB instance.
db, err := badgerdb.New(context.Background())
if err != nil {
	// handle error
}

// Open a connection to the database.
dsn := "/path/to/badgerdb/directory"
if err := db.Open(dsn); err != nil {
	// handle error
}

// Use the UserRepositoryReader and UserRepositoryWriter to interact with the user data in the database.
reader := db.GetUserRepositoryReader()
writer := db.GetUserRepositoryWriter()

// When you're done, close the connection to the database.
if err := db.Close(); err != nil {
	// handle error
}

TODO

  • add update method and check if key exists on create
  • write tests

Documentation

Overview

Package badgerdb provides a BadgerDB-backed implementation of the storage.Storage interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(parentCtx context.Context) (storage.Storage, error)

New creates and returns a new badgerDB instance.

Types

This section is empty.

Jump to

Keyboard shortcuts

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