ezdb

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: 0BSD Imports: 8 Imported by: 1

README

EZDB

EZDB is a simple and easy-to-use key-value store based on LMDB, offering a convenient and efficient way to manage data in your Go applications. This library provides a user-friendly interface to interact with the underlying LDB database.

Features

  • Supports multiple databases in a single environment
  • Customizable options such as number of readers, databases, and batch size
  • Optional logger integration

Installation

To install EZDB, run the following command:

go get https://github.com/bjornpagen/ezdb

Usage

Import the library and create a new database client:

import (
	"github.com/bjornpagen/ezdb"
)

// Create a new database client
db, err := ezdb.New("testdb")
if err != nil {
	fmt.Println("error:", err)
}

Create a reference to a new database:

// Create a new reference
ref, err := ezdb.NewRef[string, string]("ref_id", db)
if err != nil {
	fmt.Println("error:", err)
}

Insert a key-value pair into the referenced database:

// Insert key-value pair
key := "my_key"
value := "Hello, World"
if err = ref.Put(&key, &value); err != nil {
	fmt.Println("error:", err)
}

// Retrieve the value by key
if valueOut, err := ref.Get(&key); err != nil {
	fmt.Println("error:", err)
}

fmt.Println("retrieved value:", *valueOut)

License

This project is licensed under the Zero-Clause BSD License.

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue for bug reports, feature requests, or other discussions.

If you have any questions or need help, please contact the project owner or maintainers.

Happy coding!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(path string, opts ...Option) (*Client, error)

func (*Client) Close

func (db *Client) Close()

type DBRef

type DBRef[K, V any] struct {
	// contains filtered or unexported fields
}

func NewRef added in v1.4.0

func NewRef[K, V any](refID string, db *Client) (ref *DBRef[K, V], err error)

func (*DBRef[K, V]) Get

func (ref *DBRef[K, V]) Get(key *K) (val *V, err error)

func (*DBRef[K, V]) Put

func (ref *DBRef[K, V]) Put(key *K, val *V) (err error)

type Option

type Option func(option *options) error

func WithBatchSize

func WithBatchSize(batchSize uint) Option

func WithLogger

func WithLogger(logger zerolog.Logger) Option

func WithNumDBs

func WithNumDBs(numDbs uint) Option

func WithNumReaders

func WithNumReaders(numReaders uint) Option

Jump to

Keyboard shortcuts

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