Documentation ¶
Index ¶
- Variables
- type KVIterator
- type KVStore
- func (st *KVStore) Close() error
- func (st *KVStore) Delete(key string) error
- func (st *KVStore) Get(key string) ([]byte, error)
- func (st *KVStore) GetStream(key string) (io.ReadCloser, error)
- func (st *KVStore) Has(key string) (bool, error)
- func (st *KVStore) Iterator(matchFn func(string) bool) (*KVIterator, error)
- func (st *KVStore) Lock(key string) (unlock func())
- func (st *KVStore) Put(key string, value []byte) error
- func (st *KVStore) PutStream(key string, r io.Reader) 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(key string) error
- func (st *StateRW) Get(key string) ([]byte, error)
- func (st *StateRW) GetStream(key string) (io.ReadCloser, error)
- func (st *StateRW) Has(key string) (bool, error)
- func (st *StateRW) Put(key string, value []byte) error
- func (st *StateRW) PutStream(key string, r io.Reader) 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")
Functions ¶
This section is empty.
Types ¶
type KVIterator ¶
type KVIterator struct {
// contains filtered or unexported fields
}
KVIterator 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 (*KVIterator) Next ¶
func (i *KVIterator) Next() bool
Next attempts to set the next key-value pair, the return value is if there was another pair remaining
func (*KVIterator) Release ¶
func (i *KVIterator) Release()
Release releases the KVIterator and KVStore's read lock
func (*KVIterator) Value ¶
func (i *KVIterator) Value() ([]byte, error)
Value returns the next value from the KVStore
type KVStore ¶
type KVStore struct {
// contains filtered or unexported fields
}
KVStore is a very simple, yet performant key-value store
func (*KVStore) Close ¶ added in v1.3.0
Close will close the underlying storage, the mutex map locking (e.g. RLock(), Lock() will still work).
func (*KVStore) GetStream ¶
func (st *KVStore) GetStream(key string) (io.ReadCloser, error)
GetStream fetches a ReadCloser for the bytes at the supplied key location in the store
func (*KVStore) Iterator ¶
func (st *KVStore) Iterator(matchFn func(string) bool) (*KVIterator, error)
Iterator returns an Iterator for key-value pairs in the store, using supplied match function
func (*KVStore) Lock ¶ added in v1.2.0
Lock acquires a write-lock on supplied key, returning unlock function.
func (*KVStore) PutStream ¶
PutStream writes the bytes from the supplied Reader at the supplied key location in the store
func (*KVStore) RLock ¶ added in v1.2.0
RLock acquires a read-lock on supplied key, returning unlock function.
func (*KVStore) Read ¶
Read provides a read-only window to the store, holding it in a read-locked state until release
func (*KVStore) ReadFn ¶ added in v1.1.4
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, then the state has zero guarantees
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, then the state has zero guarantees