Documentation
¶
Index ¶
- Constants
- type Database
- func (db *Database) AtomicClear(newSize int) error
- func (db *Database) AtomicWrite(ctx context.Context, ops map[string][]byte) error
- func (db *Database) Close() error
- func (db *Database) Compact(start []byte, limit []byte) error
- func (db *Database) Delete(key []byte) error
- func (db *Database) Get(key []byte) ([]byte, error)
- func (db *Database) GetDatabase() map[string][]byte
- func (db *Database) Has(key []byte) (bool, error)
- func (db *Database) HealthCheck(ctx context.Context) (interface{}, error)
- func (db *Database) NewBatch() database.Batch
- func (db *Database) NewIterator() database.Iterator
- func (db *Database) NewIteratorWithPrefix(prefix []byte) database.Iterator
- func (db *Database) NewIteratorWithStart(start []byte) database.Iterator
- func (db *Database) NewIteratorWithStartAndPrefix(start, prefix []byte) database.Iterator
- func (db *Database) Put(key []byte, value []byte) error
- func (db *Database) SetDatabase(m map[string][]byte)
- type IteratorError
Constants ¶
const (
// DefaultSize is the default initial size of the database.
DefaultSize = 1 << 10
)
const Name = "memdb"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is an in-memory implementation of db.Database.
func NewFromMap ¶
NewFromMap returns a new in-memory database initialized with the provided map.
func NewWithSize ¶
NewWithSize returns a new in-memory database with the specified initial size.
func (*Database) AtomicClear ¶
AtomicClear clears the database atomically.
func (*Database) AtomicWrite ¶
AtomicWrite writes all the key-value pairs atomically.
func (*Database) GetDatabase ¶
GetDatabase returns the underlying database map. This should only be used for testing.
func (*Database) HealthCheck ¶
HealthCheck implements db.Database.
func (*Database) NewIterator ¶
NewIterator implements db.Database.
func (*Database) NewIteratorWithPrefix ¶
NewIteratorWithPrefix implements db.Database.
func (*Database) NewIteratorWithStart ¶
NewIteratorWithStart implements db.Database.
func (*Database) NewIteratorWithStartAndPrefix ¶
NewIteratorWithStartAndPrefix implements db.Database.
func (*Database) SetDatabase ¶
SetDatabase sets the underlying database map. This should only be used for testing.
type IteratorError ¶
type IteratorError struct {
Err error
}
IteratorError is a wrapper for iterator errors
func (*IteratorError) Error ¶
func (i *IteratorError) Error() error
func (*IteratorError) Key ¶
func (i *IteratorError) Key() []byte
func (*IteratorError) Next ¶
func (i *IteratorError) Next() bool
func (*IteratorError) Release ¶
func (i *IteratorError) Release()
func (*IteratorError) Value ¶
func (i *IteratorError) Value() []byte