Documentation
¶
Index ¶
- Variables
- type BasicReleaser
- type Compare
- type KVBatch
- type MdbxDB
- type MemDB
- func (p *MemDB) Capacity() int
- func (p *MemDB) Contains(key []byte) bool
- func (p *MemDB) Delete(key []byte) error
- func (p *MemDB) Find(key []byte) (rkey, value []byte, err error)
- func (p *MemDB) Free() int
- func (p *MemDB) Get(key []byte) (value []byte, err error)
- func (p *MemDB) Len() int
- func (p *MemDB) NewIterator() *dbIter
- func (p *MemDB) Put(key []byte, value []byte) error
- func (p *MemDB) Reset()
- func (p *MemDB) Size() int
- type NewValue
- type NoopReleaser
- type ReleaseSetter
- type Releaser
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = fmt.Errorf("not found") ErrIterReleased = fmt.Errorf("memdb: iterator released") )
Common errors.
var ( ErrReleased = fmt.Errorf("resource already relesed") ErrHasReleaser = fmt.Errorf("releaser already defined") )
Functions ¶
This section is empty.
Types ¶
type BasicReleaser ¶
type BasicReleaser struct {
// contains filtered or unexported fields
}
BasicReleaser provides basic implementation of Releaser and ReleaseSetter.
func (*BasicReleaser) Release ¶
func (r *BasicReleaser) Release()
Release implements Releaser.Release.
func (*BasicReleaser) Released ¶
func (r *BasicReleaser) Released() bool
Released returns whether Release method already called.
func (*BasicReleaser) SetReleaser ¶
func (r *BasicReleaser) SetReleaser(releaser Releaser)
SetReleaser implements ReleaseSetter.SetReleaser.
type KVBatch ¶
type KVBatch struct {
// contains filtered or unexported fields
}
KVBatch is a batch write for leveldb
type MemDB ¶
type MemDB struct {
// contains filtered or unexported fields
}
func New ¶
New creates a new initialized in-memory key/value DB. The capacity is the initial key/value buffer capacity. The capacity is advisory, not enforced.
This DB is append-only, deleting an entry would remove entry node but not reclaim KV buffer.
The returned DB instance is safe for concurrent use.
func (*MemDB) Contains ¶
Contains returns true if the given key are in the DB.
It is safe to modify the contents of the arguments after Contains returns.
func (*MemDB) Delete ¶
Delete deletes the value for the given key. It returns ErrNotFound if the DB does not contain the key.
It is safe to modify the contents of the arguments after Delete returns.
func (*MemDB) Find ¶
Find finds key/value pair whose key is greater than or equal to the given key. It returns ErrNotFound if the table doesn't contain such pair.
The caller should not modify the contents of the returned slice, but it is safe to modify the contents of the argument after Find returns.
func (*MemDB) Get ¶
Get gets the value for the given key. It returns error.ErrNotFound if the DB does not contain the key.
The caller should not modify the contents of the returned slice, but it is safe to modify the contents of the argument after Get returns.
func (*MemDB) NewIterator ¶
func (p *MemDB) NewIterator() *dbIter
func (*MemDB) Put ¶
Put sets the value for the given key. It overwrites any previous value for that key; a DB is not a multi-map.
It is safe to modify the contents of the arguments after Put returns.
type NoopReleaser ¶
type NoopReleaser struct{}
func (NoopReleaser) Release ¶
func (NoopReleaser) Release()
type ReleaseSetter ¶
type ReleaseSetter interface {
// SetReleaser associates the given releaser to the resources. The
// releaser will be called once coresponding resources released.
// Calling SetReleaser with nil will clear the releaser.
//
// This will panic if a releaser already present or coresponding
// resource is already released. Releaser should be cleared first
// before assigned a new one.
SetReleaser(releaser Releaser)
}
ReleaseSetter is the interface that wraps the basic SetReleaser method.