leveldb

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: MIT Imports: 14 Imported by: 1

README

go-ds-leveldb

DAOT Labs' fork of ipfs/go-ds-leveldb.

standard-readme compliant go.dev reference Build Status

A go-datastore implementation using LevelDB

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

This fork adds support for bytes-backed keys in addition to original string-backed keys, which could improve performance in some cases by preventing type conversion and reducing key size.

Lead Maintainer

Nex

Table of Contents

Install

This module can be installed like a regular go module:

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

Usage

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

Check the API documentation

Contribute

PRs accepted.

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

License

MIT

Copyright for portions of this fork are held by [Protocol Labs, 2016] as part of the original go-ds-leveldb project.

All other copyright for this fork are held by [DAOT Labs, 2020].

All rights reserved.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnimplemented   = errors.New("method not implemented")
	ErrKeyTypeNotMatch = errors.New("key type does not match")
)

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, ktype key.KeyType, 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 key.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 key.Key) (value []byte, err error)

func (Datastore) GetSize

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

func (Datastore) Has

func (a Datastore) Has(ctx context.Context, key key.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 key.Key, value []byte) (err error)

func (Datastore) Query

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

func (Datastore) Sync

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

type Options

type Options struct {
	opt.Options

	// SyncWrites is whether to sync underlying writes from the OS buffer cache
	// through to actual disk, if applicable. Setting SyncWrites can result in
	// slower writes.
	//
	// If false, and the machine crashes, then some recent writes may be lost.
	// Note that if it is just the process that crashes (and the machine does
	// not) then no writes will be lost.
	//
	// In other words, SyncWrites being false has the same semantics as a write
	// system call. SyncWrites being true means write followed by fsync.
	//
	// The default value is true.
	SyncWrites bool
}

Options extends syndtr/goleveldb/opt.Options

Jump to

Keyboard shortcuts

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