Documentation
¶
Overview ¶
Package memorydb provides an implementation of the sortedkv interfaces. The main type, Database, is an in-memory key-value store. Since the database is not persistent, the package is not suited for production use, and more suited for simplifying tests and mockups. The database is thread-safe.
Constructors ¶
The NewDatabase() constructor creates a new empty database. The FromData() constructor takes a key-value mapping and uses that as the database's contents.
Index ¶
- func FromData(data map[string]string) sortedkv.Database
- func NewDatabase() sortedkv.Database
- type Batch
- type Database
- func (d *Database) Close() error
- func (d *Database) Delete(key string) error
- func (d *Database) Get(key string) (string, error)
- func (d *Database) GetBytes(key string) ([]byte, error)
- func (d *Database) Has(key string) (bool, error)
- func (d *Database) NewBatch() sortedkv.Batch
- func (d *Database) NewIterator() sortedkv.Iterator
- func (d *Database) NewIteratorWithPrefix(prefix string) sortedkv.Iterator
- func (d *Database) NewIteratorWithRange(start string, end string) sortedkv.Iterator
- func (d *Database) Put(key string, value string) error
- func (d *Database) PutBytes(key string, value []byte) error
- type Iterator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch represents a batch and implements the batch interface.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database implements the Database interface and stores the values in memory.
func (*Database) NewIterator ¶
NewIterator creates a new iterator.
func (*Database) NewIteratorWithPrefix ¶
NewIteratorWithPrefix creates a new iterator for a given prefix.
func (*Database) NewIteratorWithRange ¶
NewIteratorWithRange creates a new iterator based on a given range.
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator provides an iterator over a key range.
func (*Iterator) ValueBytes ¶
ValueBytes returns the value converted to bytes of the current element.