store

package
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: 0 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterable

type Iterable interface {
	Store

	// Size returns the number of key-value tuples in the Iterable Store.
	Size() (int, error)

	// Iterator returns an Iterator which can be used to iterate through all
	// key-value tuples in the Iterable Store.
	Iterator() (Iterator, error)
}

Iterable is a Store that can iterate over its key-value tuples.

type Iterator

type Iterator interface {

	// Next will progress the iterator to the next element. If there are more
	// elements in the iterator, then it will return true, otherwise it will
	// return false.
	Next() bool

	// Key of the current key-value tuple. Calling Key() without calling
	// Next() or no next item in the iter will result in `ErrIndexOutOfRange`
	Key() (string, error)

	// Value will unmarshal the stored value into the given interface if
	// there's any. Calling Value() without calling Next() or no next item
	// in the iter will result in `ErrIndexOutOfRange`
	Value(value interface{}) error
}

Iterator is used to iterate through the data in the store.

type Store

type Store interface {

	// Insert writes the key-value into the store.
	Insert(key string, value interface{}) error

	// Get the value associated with the given key. This function returns
	// ErrKeyNotFound if the key cannot be found.
	Get(key string, value interface{}) error

	// Delete the value with the given key from the store. It is safe to use
	// this function to delete a key which is not in the store.
	Delete(key string) error
}

Store is a generic key-value store. The key must be of type string, though there are no restrictions on the type of the value.

Jump to

Keyboard shortcuts

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