Documentation ¶
Index ¶
- Variables
- type Iterator
- type KVStore
- func (st *KVStore) Close() error
- func (st *KVStore) Delete(ctx context.Context, key string) error
- func (st *KVStore) Get(ctx context.Context, key string) ([]byte, error)
- func (st *KVStore) GetStream(ctx context.Context, key string) (io.ReadCloser, error)
- func (st *KVStore) Has(ctx context.Context, key string) (bool, error)
- func (st *KVStore) Iterator(ctx context.Context, matchFn func(string) bool) (*Iterator, error)
- func (st *KVStore) Lock(key string) (unlock func())
- func (st *KVStore) Put(ctx context.Context, key string, value []byte) (int, error)
- func (st *KVStore) PutStream(ctx context.Context, key string, r io.Reader) (int64, error)
- func (st *KVStore) RLock(key string) (runlock func())
- func (st *KVStore) Read() *StateRO
- func (st *KVStore) ReadFn(fn func(*StateRO))
- func (st *KVStore) Update() *StateRW
- func (st *KVStore) UpdateFn(fn func(*StateRW))
- type StateRO
- type StateRW
- func (st *StateRW) Delete(ctx context.Context, key string) error
- func (st *StateRW) Get(ctx context.Context, key string) ([]byte, error)
- func (st *StateRW) GetStream(ctx context.Context, key string) (io.ReadCloser, error)
- func (st *StateRW) Has(ctx context.Context, key string) (bool, error)
- func (st *StateRW) Put(ctx context.Context, key string, value []byte) (int, error)
- func (st *StateRW) PutStream(ctx context.Context, key string, r io.Reader) (int64, error)
- func (st *StateRW) Release()
Constants ¶
This section is empty.
Variables ¶
var ErrIteratorClosed = errors.New("store/kv: iterator closed")
var ErrStateClosed = errors.New("store/kv: state closed")
ErrStateClosed is returned on further calls to states after calling Release().
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator provides a read-only iterator to all the key-value pairs in a KVStore. While the iterator is open the store is read locked, you MUST release the iterator when you are finished with it.
Please note: individual iterators are NOT concurrency safe, though it is safe to have multiple iterators running concurrently.
func (*Iterator) Next ¶
Next attempts to fetch the next key-value pair, the return value indicates whether another pair remains.
type KVStore ¶
type KVStore struct {
// contains filtered or unexported fields
}
KVStore is a very simple, yet performant key-value store
func OpenMemory ¶
func OpenStorage ¶
OpenStorage will return a new KVStore instance based on Storage, performing an initial storage.Clean().
func (*KVStore) Close ¶
Close will close the underlying storage, the mutex map locking (e.g. RLock(), Lock()) will continue to function.
func (*KVStore) GetStream ¶
GetStream fetches a ReadCloser for the bytes at the supplied key in the store.
func (*KVStore) Iterator ¶
Iterator returns an Iterator for key-value pairs in the store, using supplied match function
func (*KVStore) PutStream ¶
PutStream writes the bytes from the supplied Reader at the supplied key in the store.
func (*KVStore) Read ¶
Read provides a read-only window to the store, holding it in a read-locked state until release.
func (*KVStore) ReadFn ¶
ReadFn provides a read-only window to the store, holding it in a read-locked state until fn return..
type StateRO ¶
type StateRO struct {
// contains filtered or unexported fields
}
StateRO provides a read-only window to the store. While this state is active during the Read() function window, the entire store will be read-locked. The state is thread-safe for concurrent use UNTIL the moment that your supplied function to Read() returns.
func (*StateRO) GetStream ¶
GetStream: see KVStore.GetStream(). Returns error if state already closed.
type StateRW ¶
type StateRW struct {
// contains filtered or unexported fields
}
StateRW provides a read-write window to the store. While this state is active during the Update() function window, the entire store will be locked. The state is thread-safe for concurrent use UNTIL the moment that your supplied function to Update() returns.
func (*StateRW) GetStream ¶
GetStream: see KVStore.GetStream(). Returns error if state already closed.