leveldbx

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DbRelativePath leveldb relative path
	DbRelativePath = "leveldb"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyFunc

type ApplyFunc func(opts *LdbOptions)

type DB

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

func OpenDB

func OpenDB[K any, V any](name string, opts ...Option) (*DB[K, V], error)

OpenDB open a leveldb with the given name and opts As usual, when you call OpenDB(), `defer db.close ()` is used to Close it

To use bloom filter:

leveldbx.OpenDB("foo", leveldbx.WithLevelDBOpts(&opt.Options{Filter: filter.NewBloomFilter(10),}))

func (*DB[K, V]) Close

func (db *DB[K, V]) Close() error

Close to close level db

func (*DB[K, V]) CloseQuietly added in v1.0.7

func (db *DB[K, V]) CloseQuietly()

CloseQuietly to close level db ignore error

func (*DB[K, V]) DecodeKey added in v1.0.2

func (db *DB[K, V]) DecodeKey(data []byte) (K, error)

func (*DB[K, V]) DecodeVal added in v1.0.2

func (db *DB[K, V]) DecodeVal(data []byte) (V, error)

func (*DB[K, V]) DeleteBatch

func (db *DB[K, V]) DeleteBatch(keys ...K) error

func (*DB[K, V]) DeleteBatchWithWriteOpts

func (db *DB[K, V]) DeleteBatchWithWriteOpts(keys []K, wo *opt.WriteOptions) error

func (*DB[K, V]) EncodeKey added in v1.0.2

func (db *DB[K, V]) EncodeKey(k K) ([]byte, error)

func (*DB[K, V]) EncodeVal added in v1.0.2

func (db *DB[K, V]) EncodeVal(v V) ([]byte, error)

func (*DB[K, V]) ForRange

func (db *DB[K, V]) ForRange(consumer func(key K, val V)) error

ForRange add for range

func (*DB[K, V]) ForRangeWithOpts

func (db *DB[K, V]) ForRangeWithOpts(slice *util.Range, ro *opt.ReadOptions, consumer func(key K, val V)) error

ForRangeWithOpts for range with *util.Range and LdbOptions *util.Range can be:

&util.Range{Start: []byte("foo"), Limit: []byte("xoo")}

or can be:

util.BytesPrefix([]byte("foo-")

func (*DB[K, V]) Get

func (db *DB[K, V]) Get(key K) (v V, err error)

Get key from leveldb

func (*DB[K, V]) GetWithReadOpts

func (db *DB[K, V]) GetWithReadOpts(key K, readOpts *opt.ReadOptions) (v V, err error)

GetWithReadOpts get key from leveldb with read LdbOptions

func (*DB[K, V]) Put

func (db *DB[K, V]) Put(key K, val V) error

Put key value pair to leveldb

func (*DB[K, V]) PutBatch

func (db *DB[K, V]) PutBatch(batch *leveldb.Batch) error

func (*DB[K, V]) PutBatchWithWriteOpts

func (db *DB[K, V]) PutBatchWithWriteOpts(batch *leveldb.Batch, wo *opt.WriteOptions) error

func (*DB[K, V]) PutWithWriteOpts

func (db *DB[K, V]) PutWithWriteOpts(key K, val V, wo *opt.WriteOptions) error

PutWithWriteOpts put key value pair to leveldb with write LdbOptions

func (*DB[K, V]) Seek

func (db *DB[K, V]) Seek(startKey K, consumer func(key K, val V)) error

Seek seek startKey, then for range

func (*DB[K, V]) SetCodec

func (db *DB[K, V]) SetCodec(codec codec.LdbCodec[K, V])

SetCodec set leveldb codec

func (*DB[K, V]) Size added in v1.0.3

func (db *DB[K, V]) Size() int

Size returns db size

type LdbOptions added in v1.0.4

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

LdbOptions private LdbOptions

func DefaultOptions

func DefaultOptions() *LdbOptions

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithLevelDBOpts

func WithLevelDBOpts(levelDBOpts *opt.Options) Option

WithLevelDBOpts set leveldb opt.Options

func WithPath

func WithPath(path string) Option

WithPath set dir path of db files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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