leveldb

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: MIT Imports: 12 Imported by: 144

README

go-ds-leveldb

standard-readme compliant GoDoc Build Status

A go-datastore implementation using LevelDB

go-ds-leveldb implements the go-datastore interface using a LevelDB backend.

Lead Maintainer

Steven Allen

Table of Contents

Install

This module can be installed like a regular go module:

go get github.com/ipfs/go-ds-leveldb

It uses Gx to manage dependencies. You can use make deps to rewrite imports to the gx-specified versions.

Usage

import "github.com/ipfs/go-ds-leveldb"

Check the GoDoc documentation

Contribute

PRs accepted.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © Protocol Labs, Inc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Datastore

type Datastore struct {
	DB *leveldb.DB
	// contains filtered or unexported fields
}

func NewDatastore

func NewDatastore(path string, opts *Options) (*Datastore, error)

NewDatastore returns a new datastore backed by leveldb

for path == "", an in memory backend will be chosen

func (*Datastore) Batch

func (d *Datastore) Batch(ctx context.Context) (ds.Batch, error)

func (*Datastore) Close

func (d *Datastore) Close() (err error)

LevelDB needs to be closed.

func (Datastore) Delete

func (a Datastore) Delete(ctx context.Context, key ds.Key) (err error)

func (*Datastore) DiskUsage

func (d *Datastore) DiskUsage(ctx context.Context) (uint64, error)

DiskUsage returns the current disk size used by this levelDB. For in-mem datastores, it will return 0.

func (Datastore) Get

func (a Datastore) Get(ctx context.Context, key ds.Key) (value []byte, err error)

func (Datastore) GetSize

func (a Datastore) GetSize(ctx context.Context, key ds.Key) (size int, err error)

func (Datastore) Has

func (a Datastore) Has(ctx context.Context, key ds.Key) (exists bool, err error)

func (*Datastore) NewTransaction

func (d *Datastore) NewTransaction(ctx context.Context, readOnly bool) (ds.Txn, error)

func (Datastore) Put

func (a Datastore) Put(ctx context.Context, key ds.Key, value []byte) (err error)

func (Datastore) Query

func (a Datastore) Query(ctx context.Context, q dsq.Query) (dsq.Results, error)

func (Datastore) Sync added in v0.4.0

func (a Datastore) Sync(ctx context.Context, prefix ds.Key) error

type Options

type Options opt.Options

Options is an alias of syndtr/goleveldb/opt.Options which might be extended in the future.

Jump to

Keyboard shortcuts

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