kv

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2019 License: MIT Imports: 8 Imported by: 5

README

KV

CircleCI Go Report Coverage Status

A flexible and extensible library for key-value storage.

  • Multiple encoding/decoding formats
  • Persistent database drivers
  • In-memory database drivers
  • Time-to-live caching
  • Safe for concurrent use
Benchmarks results
Database Number of iterations run Time (ns/op) Memory (bytes/op)
LevelDB 2000 10784337 4397224
BadgerDB 100 200012411 200012411

Built with ❤ by Ren.

Documentation

Overview

Package kv defines a standard interface for key-value stores and key-value iterators. It provides persistent implementations using BadgerDB. It provides non-persistent implementations using a concurrent-safe in-memory map.

Index

Constants

This section is empty.

Variables

View Source
var (
	// NewJSON returns a key-value store that marshals and unmarshals values
	// using the standard Golang JSON marshalers. For more information, see
	// https://golang.org/pkg/encoding/json.
	NewJSON = json.New

	// NewGob returns a key-value store that encodes and decodes values using
	// gob. For more information, see https://golang.org/pkg/encoding/gob.
	NewGob = gob.New
)
View Source
var (
	// NewBadgerDB returns a key-value database that is implemented using
	// BadgerDB. For more information, see https://github.com/dgraph-io/badger.
	NewBadgerDB = badgerdb.New

	// NewMemDB returns a key-value database that is implemented in-memory. This
	// implementation is fast, but does not store data on-disk. A time-to-live can
	// be used to automatically delete key-value tuples after they have been in the
	// database for more than a specific duration. A time-to-live of zero will keep
	// key-value tuples until they are explicitly deleted. It is safe for concurrent
	// use.
	NewMemDB = memdb.New

	// NewLevelDB returns a key-value database that is implemented using
	// LevelDB. For more information, see https://github.com/syndtr/goleveldb.
	NewLevelDB = leveldb.New
)
View Source
var (
	// ErrNotFound is returned when there is no value associated with a key.
	ErrNotFound = db.ErrNotFound
)
View Source
var (
	// NewTTLCache returns a cache that wraps an underlying store. Keys that have
	// no been accessed for the specified duration will be automatically deleted
	// from the underlying store. It is safe for concurrent use, as long as the
	// underlying store is also safe for concurrent use.
	NewTTLCache = cache.NewTTL
)

Functions

This section is empty.

Types

type Iterable

type Iterable = store.Iterable

TODO: Comment!

type Iterator

type Iterator = store.Iterator

TODO: Comment!

type Store

type Store = store.Store

TODO: Comment!

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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