Documentation
¶
Index ¶
- Variables
- type DataStore
- func (dataStore *DataStore) Close() error
- func (dataStore *DataStore) Delete(key []byte) error
- func (dataStore *DataStore) DeleteWithExists(key []byte) (bool, error)
- func (dataStore *DataStore) Get(key []byte) ([]byte, error)
- func (dataStore *DataStore) ListKeys() ([]string, error)
- func (dataStore *DataStore) Merge() error
- func (dataStore *DataStore) Put(key []byte, value []byte) error
- func (dataStore *DataStore) Size() int
- func (dataStore *DataStore) Sync() error
Constants ¶
This section is empty.
Variables ¶
var ( ErrKeyNotFound = errors.New("key not found") ErrNotExist = errors.New("datastore does not exist") )
Functions ¶
This section is empty.
Types ¶
type DataStore ¶
type DataStore struct {
// contains filtered or unexported fields
}
func Create ¶
Create creates a datastore at the given path, if the path exists and an existing key store is found, it returns an error. If the path is a file, or is a non empty directory, an error is returned. Otherwise, the directory is created (along with all it's parents), and the datastore is initialized
func Open ¶
Open opens the datastore at the specified location. If the datastore does not exist, an error is returned
func (*DataStore) Close ¶
Close closes the datastore, writes pending changes (if any), and frees resources
func (*DataStore) Delete ¶
Delete deletes the value associated with the specified key. No error will be returned if the key does not exist. An error is returned if the deletion failed due to some other reason.
func (*DataStore) DeleteWithExists ¶
DeleteWithExists deletes the value associated with the specified key. No error will be returned if the key does not exist. An error is returned if the deletion failed due to some other reason. true is returned if the key existed, and false if the key did not exist
func (*DataStore) Get ¶
Get returns the value associated with the key. If the key does not exist, `ErrNotFound` is returned, in case of any other errors, the error is returned
func (*DataStore) ListKeys ¶
ListKeys returns a list of all keys in the datastore. Note: This is intended to be used for debug or inspection.
func (*DataStore) Put ¶
Put sets the value for the specified key. It returns an error if the operation was not successful