storage

package
v0.0.0-...-f714a01 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2016 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Overview

The storage package defines a key-value based storage engine interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeCounter

func DecodeCounter(buf []byte) uint64

DecodeCounter decodes bytes into a uint64.

func EncodeCounter

func EncodeCounter(n uint64) []byte

EncodeCounter encodes an uint64 into bytes.

Types

type Engine

type Engine interface {
	// Get takes a key and returns the associated bytes.
	Get(part, key string) ([]byte, error)

	// Set takes a key and bytes and writes it to storage.
	Set(part, key string, value []byte) error

	// Delete takes a key and deletes the entry from storage.
	Delete(part, key string) error

	// Incr increments an integer or sets it to one for new entries.
	Incr(part, key string) (uint64, error)

	// Multi takes a function that takes a transaction value. For storages
	// that support batch writes, this should be used.
	Multi(func(Tx) error) error
}

Engine is an interface for defining storage engines.

type Initializer

type Initializer func(Options) (Engine, error)

Initializer is a function type that takes options and returns an initialized storage engine.

type Options

type Options map[string]interface{}

Options is a general purpose map for accessing options for storage engines.

func (Options) Get

func (o Options) Get(k string) interface{}

Get returns the interface value associated with the key.

func (Options) GetBool

func (o Options) GetBool(k string) bool

GetBool returns a boolean value associated with the key. If the conversion fails, this will panic.

func (Options) GetInt

func (o Options) GetInt(k string) int

GetInt returns an integer value associated with the key. If the conversion fails, this will panic.

func (Options) GetString

func (o Options) GetString(k string) string

GetString returns a string value associated with the key. If the conversion fails, this will panic.

type Tx

type Tx interface {
	// Get takes a key and returns the associated bytes.
	Get(part, key string) ([]byte, error)

	// Set takes a key and bytes and writes it to storage.
	Set(part, key string, value []byte) error

	// Delete takes a key and deletes the entry from storage.
	Delete(part, key string) error

	// Incr increments an integer or sets it to one for new entries.
	Incr(part, key string) (uint64, error)
}

Tx is an interface for representing a storage transaction. The calls executed by a transaction must be wrapped in a transaction context by engine implementations.

Directories

Path Synopsis
The boltdb package implements a storage engine for BoltDB.
The boltdb package implements a storage engine for BoltDB.
The memory package implements an in-memory storage storage.
The memory package implements an in-memory storage storage.

Jump to

Keyboard shortcuts

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