Documentation ¶
Index ¶
- Variables
- type DBStore
- func (s *DBStore) Close() error
- func (s *DBStore) Delete(key string) (err error)
- func (s *DBStore) Get(key string, i interface{}) (err error)
- func (s *DBStore) Iterate(prefix string, iterFunc iterFunction) (err error)
- func (s *DBStore) Put(key string, i interface{}) (err error)
- func (s *DBStore) WriteBatch(batch *StoreBatch) error
- type Store
- type StoreBatch
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("ErrorNotFound")
ErrNotFound is returned when no results are returned from the database
Functions ¶
This section is empty.
Types ¶
type DBStore ¶
type DBStore struct {
// contains filtered or unexported fields
}
DBStore uses LevelDB to store values.
func NewDBStore ¶
NewDBStore creates a new instance of DBStore.
func NewInmemoryStore ¶
func NewInmemoryStore() *DBStore
NewInmemoryStore returns a new instance of DBStore. To be used only in tests and simulations.
func (*DBStore) Get ¶
Get retrieves a persisted value for a specific key. If there is no results ErrNotFound is returned. The provided parameter should be either a byte slice or a struct that implements the encoding.BinaryUnmarshaler interface
func (*DBStore) Iterate ¶ added in v0.5.0
Iterate entries (key/value pair) which have keys matching the given prefix
func (*DBStore) WriteBatch ¶ added in v0.5.6
func (s *DBStore) WriteBatch(batch *StoreBatch) error
WriteBatch executes the batch on the underlying database.
type Store ¶
type Store interface { Get(key string, i interface{}) (err error) Put(key string, i interface{}) (err error) Delete(key string) (err error) Iterate(prefix string, iterFunc iterFunction) (err error) WriteBatch(batch *StoreBatch) (err error) Close() error }
Store defines methods required to get, set, delete values for different keys and close the underlying resources.
type StoreBatch ¶ added in v0.5.6
StoreBatch is a wrapper around a leveldb batch that takes care of the proper encoding.
func (*StoreBatch) Delete ¶ added in v0.5.6
func (b *StoreBatch) Delete(key string)
Delete adds a delete operation to the underlying batch.
func (*StoreBatch) Put ¶ added in v0.5.6
func (b *StoreBatch) Put(key string, i interface{}) (err error)
Put encodes the value and puts a corresponding Put operation into the underlying batch. This only returns an error if the encoding failed.