Documentation ¶
Index ¶
- type Database
- func (db *Database) Delete(key string)
- func (db *Database) Export(filename string) (err error)
- func (db *Database) Get(key string) ([]byte, *ErrorType)
- func (db *Database) Insert(key string, value []byte, overwrite bool) *ErrorType
- func (db *Database) Name() string
- func (db *Database) SetName(name string) *ErrorType
- func (db *Database) ToRawMap() map[string][]byte
- type ErrorType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database encapsulates the underlying datastore, and other related metadata. Restrictions : - The length of name should fit in 1 byte. So the maximum length is math.MaxUint8
func New ¶
New creates and return a database with a given name. Returns nil if creation is not successful
func Open ¶
Open reads in a database from disk, and creates a new one in memory and on disk if it can't find one with the supplied filename
func (*Database) Delete ¶
Delete removes a key from the database. It behaves the same way as the in build delete wherein it doesn't return anything and does nothing if the key doesn't exist
func (*Database) Export ¶
Export writes out the database to a file. This overwrites exising files and dumps the entire data into the file
func (*Database) Get ¶
Get a value for a key from the map. Return DatabaseKeyNotPresent if not in map
func (*Database) Insert ¶
Insert key value pair into the database. Overwrite existing value is parameter is true. No validation on the data is performed.