Documentation ¶
Overview ¶
Package db provides utilities for interacting with BadgerDB v4.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BadgerDB ¶
type BadgerDB struct {
// contains filtered or unexported fields
}
BadgerDB wraps a Badger DB with additional context and configuration.
func NewBadgerDB ¶
NewBadgerDB creates a new BadgerDB instance with the provided Options. It defaults to using a background context if no context is provided.
Example usage:
ctx := context.Background() db, err := NewBadgerDB(ctx, "/tmp/mydb", opts...)
func (*BadgerDB) Exists ¶
Exists checks if a key exists in the BadgerDB.
Returns a boolean indicating if the key exists and any error encountered. It returns true and nil error if the key exists, false and nil error if the key does not exist. If an error other than ErrKeyNotFound is encountered during the operation, it returns false and the error.
Example usage:
exists, err := db.Exists("myKey")
func (*BadgerDB) GarbageCollect ¶
GarbageCollect runs a value log garbage collection on the BadgerDB, provided the rewrite ratio is more than 0.7 (70%).
Example usage:
err := db.GarbageCollect()
type Db ¶
type Db struct {
// contains filtered or unexported fields
}