Documentation ¶
Overview ¶
nolint
Index ¶
- Constants
- type BTreeCacheWrap
- func (b BTreeCacheWrap) CacheWrap() KVCacheWrap
- func (b BTreeCacheWrap) Delete(key []byte)
- func (b BTreeCacheWrap) Discard()
- func (b BTreeCacheWrap) Get(key []byte) []byte
- func (b BTreeCacheWrap) Has(key []byte) bool
- func (b BTreeCacheWrap) Iterator(start, end []byte) Iterator
- func (b BTreeCacheWrap) NewBatch() Batch
- func (b BTreeCacheWrap) ReverseIterator(start, end []byte) Iterator
- func (b BTreeCacheWrap) Set(key, value []byte)
- func (b BTreeCacheWrap) Write()
- type BTreeCacheable
- type Batch
- type CacheableKVStore
- type CommitID
- type CommitKVStore
- type EmptyKVStore
- func (e EmptyKVStore) Delete(key []byte)
- func (e EmptyKVStore) Get(key []byte) []byte
- func (e EmptyKVStore) Has(key []byte) bool
- func (e EmptyKVStore) Iterator(start, end []byte) Iterator
- func (e EmptyKVStore) NewBatch() Batch
- func (e EmptyKVStore) ReverseIterator(start, end []byte) Iterator
- func (e EmptyKVStore) Set(key, value []byte)
- type Iterator
- type KVCacheWrap
- type KVStore
- type Model
- type NonAtomicBatch
- type Op
- type ReadOnlyKVStore
- type SetDeleter
- type SliceIterator
Constants ¶
const ( // DefaultFreeListSize is the size we hold for free node in btree DefaultFreeListSize = btree.DefaultFreeListSize )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 writen to this store, or rolled back
type CacheableKVStore ¶
type CacheableKVStore = weave.CacheableKVStore
func MemStore ¶
func MemStore() CacheableKVStore
MemStore returns a simple implementation useful for tests. There is no persistence here....
type CommitKVStore ¶
type CommitKVStore = weave.CommitKVStore
type EmptyKVStore ¶
type EmptyKVStore struct{}
EmptyKVStore never holds any data, used as a base layer to test caching
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
type KVCacheWrap ¶
type KVCacheWrap = weave.KVCacheWrap
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 writen 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) 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 (Op) Apply ¶
func (o Op) Apply(out SetDeleter)
type ReadOnlyKVStore ¶
type ReadOnlyKVStore = weave.ReadOnlyKVStore
type SetDeleter ¶
type SetDeleter = weave.SetDeleter
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) 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.