Documentation ¶
Overview ¶
Package kv provides a Charm Cloud backed BadgerDB.
Index ¶
- func OptionsWithEncryption(opt badger.Options, encKey []byte, cacheSize int64) (badger.Options, error)
- type KV
- func (kv *KV) Client() *client.Client
- func (kv *KV) Close() error
- func (kv *KV) Commit(txn *badger.Txn, callback func(error)) error
- func (kv *KV) Delete(key []byte) error
- func (kv *KV) Get(key []byte) ([]byte, error)
- func (kv *KV) Keys() ([][]byte, error)
- func (kv *KV) NewStream() *badger.Stream
- func (kv *KV) NewTransaction(update bool) (*badger.Txn, error)
- func (kv *KV) Reset() error
- func (kv *KV) Set(key []byte, value []byte) error
- func (kv *KV) SetReader(key []byte, value io.Reader) error
- func (kv *KV) Sync() error
- func (kv *KV) View(fn func(txn *badger.Txn) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type KV ¶
KV provides a Charm Cloud backed BadgerDB key-value store.
KV supports regular Badger transactions, and backs up the data to the Charm Cloud. It will allow for syncing across machines linked with a Charm account. All data is encrypted by Badger on the local disk using a Charm user's encryption keys. Diffs are also encrypted locally before being synced to the Charm Cloud.
func OpenWithDefaults ¶
OpenWithDefaults opens a Charm Cloud managed Badger DB instance with the default settings pulled from environment variables.
func (*KV) NewTransaction ¶
NewTransaction creates a new *badger.Txn with a Charm Cloud managed timestamp.
func (*KV) Reset ¶
Reset deletes the local copy of the Badger DB and rebuilds with a fresh sync from the Charm Cloud.
func (*KV) Set ¶
Set is a convenience method for setting a key and value. It creates and commits a new transaction for the update.
func (*KV) SetReader ¶
SetReader is a convenience method to set the value for a key to the data read from the provided io.Reader.