Documentation
¶
Overview ¶
Package kvfs provides a simple persistent key-value store.
The API is very simple, you can:
- Put() entries - Get() entries - Delete() entries - Keys() dump all keys in a bucket.
kvfs uses BoltDB for storage.
Index ¶
- Variables
- type KvS
- func (rcv *KvS) Buckets() []string
- func (rcv *KvS) Close() error
- func (rcv *KvS) Delete(bucket, key string) error
- func (rcv *KvS) DeleteBucket(bucket string) error
- func (rcv *KvS) Get(bucket, key string) ([]byte, error)
- func (rcv *KvS) Keys(bucket string) []string
- func (rcv *KvS) Put(bucket, key string, value []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned when the key supplied to a Get or Delete // method does not exist in the database. ErrNotFound = errors.New("kvs: key not found") // ErrBadValue is returned when the value supplied to the Put method // is nil. ErrBadValue = errors.New("kvs: bad value") // ErrBucketNotFound is returned when the bucket name supplied does not exists ErrBucketNotFound = errors.New("kvs: bucket not found") )
Functions ¶
This section is empty.
Types ¶
type KvS ¶
type KvS struct {
// contains filtered or unexported fields
}
KvS is the key value store. Use the Open() method to create one, and Close() it when done.
func Open ¶
Open a key-value store. "filename" is the full path to the database file, any leading directories must have been created already. File is created with mode 0640 if needed.
"bucket" is a collections of key/value pairs within the database. All keys in a bucket must be unique.
func (*KvS) Delete ¶
Delete the entry with the given key. If no such key is present in the store, it returns ErrNotFound.
func (*KvS) DeleteBucket ¶
DeleteBucket deletes a bucket. Returns an error if the bucket cannot be found or if the key represents a non-bucket value.
func (*KvS) Get ¶
Get an entry from the store. If the key is not present in the store, Get returns ErrNotFound.