-
Notifications
You must be signed in to change notification settings - Fork 23
/
kvstore.go
24 lines (18 loc) · 907 Bytes
/
kvstore.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package kvstore
// KVStore is an interface for a persistence backend, storing key-value pairs.
type KVStore interface {
// Put stores an entry in the key-value store
Put(schema, key string, value []byte) error
// Get fetches one entry
Get(schema, key string) (value []byte, exist bool, err error)
// Delete an entry
Delete(schema, key string) error
// Iterate iterates over all entries in the key value store.
// The result will be sent to the channel, which is closed after the last entry.
// For simplicity, the return type is an string array with key, value.
// If you have binary values, you can safely cast back to []byte.
Iterate(schema, keyPrefix string) (entries chan [2]string)
// IterateKeys iterates over all keys in the key value store.
// The keys will be sent to the channel, which is closed after the last entry.
IterateKeys(schema, keyPrefix string) (keys chan string)
}