Documentation ¶
Index ¶
- type Config
- type KeyValueDB
- func (m *KeyValueDB) Close() error
- func (m *KeyValueDB) DropAll() error
- func (m *KeyValueDB) Get(key []byte) (value []byte, ok bool, err error)
- func (m *KeyValueDB) Keys() ([]string, error)
- func (KeyValueDB) MarshalBinary() ([]byte, error)
- func (m *KeyValueDB) Put(key []byte, value []byte) error
- func (*KeyValueDB) UnmarshalBinary([]byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeyValueDB ¶
type KeyValueDB struct { Config // contains filtered or unexported fields }
KeyValueDB is a key-value database which spaGO can use to efficiently store large data.
func NewDefaultKeyValueDB ¶
func NewDefaultKeyValueDB(config Config) *KeyValueDB
NewDefaultKeyValueDB returns a new KeyValueDB.
func (*KeyValueDB) Close ¶
func (m *KeyValueDB) Close() error
Close closes the underlying DB. It's crucial to call it to ensure all the pending updates make their way to disk.
func (*KeyValueDB) DropAll ¶
func (m *KeyValueDB) DropAll() error
DropAll would drop all the data stored. Readings or writings performed during this operation may result in panics.
func (*KeyValueDB) Get ¶
func (m *KeyValueDB) Get(key []byte) (value []byte, ok bool, err error)
Get returns the value associated to the given key, if it exists.
func (*KeyValueDB) Keys ¶
func (m *KeyValueDB) Keys() ([]string, error)
Keys returns all the keys from the DB.
func (KeyValueDB) MarshalBinary ¶ added in v0.4.0
func (KeyValueDB) MarshalBinary() ([]byte, error)
MarshalBinary prevents KeyValueDB to be encoded to binary representation.
It never makes sense to encode/decode a KeyValueDB value, for example when used as a model parameter. So this method always returns nil, and no errors.
func (*KeyValueDB) Put ¶
func (m *KeyValueDB) Put(key []byte, value []byte) error
Put sets a new key/value pair in the DB.
func (*KeyValueDB) UnmarshalBinary ¶ added in v0.4.0
func (*KeyValueDB) UnmarshalBinary([]byte) error
UnmarshalBinary prevents KeyValueDB to be decoded from binary representation.
It never makes sense to encode/decode a KeyValueDB value, for example when used as a model parameter. So this method always does not modify the receiver in any way, and never returns errors.