store

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2019 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// DefaultFreeListSize is the size we hold for free node in btree
	DefaultFreeListSize = btree.DefaultFreeListSize
)

Variables

View Source
var Pair = weave.Pair

Pair is an alias to function in root package

Functions

func LogableStore added in v0.11.2

func LogableStore() (CacheableKVStore, ShowOpser)

LogableStore will return a store, along with insight into all operations that were run on it

Types

type BTreeCacheWrap

type BTreeCacheWrap struct {
	// contains filtered or unexported fields
}

BTreeCacheWrap places a btree cache over a KVStore

func NewBTreeCacheWrap

func NewBTreeCacheWrap(kv ReadOnlyKVStore, batch Batch,
	free *btree.FreeList) BTreeCacheWrap

NewBTreeCacheWrap initializes a BTree to cache around this kv store. Use ReadOnlyKVStore to emphasize that all writes must go through the Batch.

free may be nil, but set to an existing list to reuse it for memory savings

func (BTreeCacheWrap) CacheWrap

func (b BTreeCacheWrap) CacheWrap() KVCacheWrap

CacheWrap layers another BTree on top of this one. Don't change horses in mid-stream....

Uses NonAtomicBatch as it is only backed by another in-memory batch

func (BTreeCacheWrap) Delete

func (b BTreeCacheWrap) Delete(key []byte)

Delete deletes from the BTree and to the batch

func (BTreeCacheWrap) Discard

func (b BTreeCacheWrap) Discard()

Discard invalidates this CacheWrap and releases all data

TODO: currently noop....leave it to the garbage collector

func (BTreeCacheWrap) Get

func (b BTreeCacheWrap) Get(key []byte) []byte

Get reads from btree if there, else backing store

func (BTreeCacheWrap) Has

func (b BTreeCacheWrap) Has(key []byte) bool

Has reads from btree if there, else backing store

func (BTreeCacheWrap) Iterator

func (b BTreeCacheWrap) Iterator(start, end []byte) Iterator

Iterator over a domain of keys in ascending order. Combines results from btree and backing store

func (BTreeCacheWrap) NewBatch

func (b BTreeCacheWrap) NewBatch() Batch

NewBatch returns a non-atomic batch that eventually may write to our cachewrap

func (BTreeCacheWrap) ReverseIterator

func (b BTreeCacheWrap) ReverseIterator(start, end []byte) Iterator

ReverseIterator over a domain of keys in descending order. Combines results from btree and backing store

func (BTreeCacheWrap) Set

func (b BTreeCacheWrap) Set(key, value []byte)

Set writes to the BTree and to the batch

func (BTreeCacheWrap) Write

func (b BTreeCacheWrap) Write()

Write syncs with the underlying store. And then cleans up

type BTreeCacheable

type BTreeCacheable struct {
	KVStore
}

BTreeCacheable adds a simple btree-based CacheWrap strategy to a KVStore

func (BTreeCacheable) CacheWrap

func (b BTreeCacheable) CacheWrap() KVCacheWrap

CacheWrap returns a BTreeCacheWrap that can be later written to this store, or rolled back

type Batch

type Batch = weave.Batch

Batch is an alias to interface in root package

type CacheableKVStore

type CacheableKVStore = weave.CacheableKVStore

CacheableKVStore is an alias to interface in root package

func MemStore

func MemStore() CacheableKVStore

MemStore returns a simple implementation useful for tests. There is no persistence here....

type CommitID

type CommitID = weave.CommitID

CommitID is an alias to interface in root package

type CommitKVStore

type CommitKVStore = weave.CommitKVStore

CommitKVStore is an alias to interface in root package

type EmptyKVStore

type EmptyKVStore struct{}

EmptyKVStore never holds any data, used as a base layer to test caching

func (EmptyKVStore) Delete

func (e EmptyKVStore) Delete(key []byte)

Delete is a noop

func (EmptyKVStore) Get

func (e EmptyKVStore) Get(key []byte) []byte

Get always returns nil

func (EmptyKVStore) Has

func (e EmptyKVStore) Has(key []byte) bool

Has always returns false

func (EmptyKVStore) Iterator

func (e EmptyKVStore) Iterator(start, end []byte) Iterator

Iterator is always empty

func (EmptyKVStore) NewBatch

func (e EmptyKVStore) NewBatch() Batch

NewBatch returns a batch that can write to this tree later

func (EmptyKVStore) ReverseIterator

func (e EmptyKVStore) ReverseIterator(start, end []byte) Iterator

ReverseIterator is always empty

func (EmptyKVStore) Set

func (e EmptyKVStore) Set(key, value []byte)

Set is a noop

type Iterator

type Iterator = weave.Iterator

Iterator is an alias to interface in root package

type KVCacheWrap

type KVCacheWrap = weave.KVCacheWrap

KVCacheWrap is an alias to interface in root package

type KVStore

type KVStore = weave.KVStore

KVStore is an alias to interface in root package

func NewRecordingStore added in v0.2.1

func NewRecordingStore(db KVStore) KVStore

NewRecordingStore initializes a recording store wrapping this base store, using cached alternative if possible

We need to expose this optional functionality through the interface wrapper so downstream components (like Savepoint) can use reflection to CacheWrap.

type Model

type Model = weave.Model

Model is an alias to interface in root package

type NonAtomicBatch

type NonAtomicBatch struct {
	// contains filtered or unexported fields
}

NonAtomicBatch just piles up ops and executes them later on the underlying store. Can be used when there is no better option (for in-memory stores).

NOTE: Never use this for KVStores that are persistent

func NewNonAtomicBatch

func NewNonAtomicBatch(out SetDeleter) *NonAtomicBatch

NewNonAtomicBatch creates an empty batch to be later written to the KVStore

func (*NonAtomicBatch) Delete

func (b *NonAtomicBatch) Delete(key []byte)

Delete adds a delete operation to the batch

func (*NonAtomicBatch) Set

func (b *NonAtomicBatch) Set(key, value []byte)

Set adds a set operation to the batch

func (*NonAtomicBatch) ShowOps added in v0.11.2

func (b *NonAtomicBatch) ShowOps() []Op

ShowOps is instrumentation for testing, it returns a copy of the internal Ops list

func (*NonAtomicBatch) Write

func (b *NonAtomicBatch) Write()

Write writes all the ops to the underlying store and resets

type Op

type Op struct {
	// contains filtered or unexported fields
}

Op is either set or delete

func DelOp

func DelOp(key []byte) Op

DelOp is a helper to create a del operation

func SetOp

func SetOp(key, value []byte) Op

SetOp is a helper to create a set operation

func (Op) Apply

func (o Op) Apply(out SetDeleter)

Apply performs the stored operation on a writeable store

func (Op) IsSetOp added in v0.11.2

func (o Op) IsSetOp() bool

IsSetOp returns true if it is setting (false implies delete)

func (Op) Key added in v0.11.2

func (o Op) Key() []byte

Key returns a copy of the Key

type ReadOnlyKVStore

type ReadOnlyKVStore = weave.ReadOnlyKVStore

ReadOnlyKVStore is an alias to interface in root package

type Recorder added in v0.2.1

type Recorder interface {
	KVPairs() map[string][]byte
}

Recorder interface is implemented by anything returned from NewRecordingStore

type SetDeleter

type SetDeleter = weave.SetDeleter

SetDeleter is an alias to interface in root package

type ShowOpser added in v0.11.2

type ShowOpser interface {
	ShowOps() []Op
}

ShowOpser returns an ordered list of all operations performed

type SliceIterator

type SliceIterator struct {
	// contains filtered or unexported fields
}

SliceIterator wraps an Iterator over a slice of models

TODO: make this private and only expose Iterator interface????

func NewSliceIterator

func NewSliceIterator(data []Model) *SliceIterator

NewSliceIterator creates a new Iterator over this slice

func (*SliceIterator) Close

func (s *SliceIterator) Close()

Close releases the Iterator.

func (*SliceIterator) Key

func (s *SliceIterator) Key() (key []byte)

Key returns the key of the cursor.

func (*SliceIterator) Next

func (s *SliceIterator) Next()

Next moves the iterator to the next sequential key in the database, as defined by order of iteration.

If Valid returns false, this method will panic.

func (*SliceIterator) Valid

func (s *SliceIterator) Valid() bool

Valid implements Iterator and returns true iff it can be read

func (*SliceIterator) Value

func (s *SliceIterator) Value() (value []byte)

Value returns the value of the cursor.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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