leveldb

package module
v0.4.3-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: MIT Imports: 13 Imported by: 0

README

go-ds-leveldb

Fork of ipfs/go-ds-leveldb used by BDWare projects.

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.

Lead Maintainer

Nex

Table of Contents

Install

This module can be installed like a regular go module:

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

Usage

import "github.com/bdware/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 [The BDWare Authors, 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 bachend will be chosen

func (*Datastore) Batch

func (d *Datastore) Batch() (ds.Batch, error)

func (*Datastore) Close

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

LevelDB needs to be closed.

func (Datastore) Delete

func (a Datastore) Delete(key key.Key) (err error)

func (*Datastore) DiskUsage

func (d *Datastore) DiskUsage() (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(key key.Key) (value []byte, err error)

func (Datastore) GetSize

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

func (Datastore) Has

func (a Datastore) Has(key key.Key) (exists bool, err error)

func (*Datastore) NewTransaction

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

func (Datastore) Put

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

func (Datastore) Query

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

func (Datastore) Sync

func (a Datastore) Sync(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