forked from streamingfast/kvdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.go
42 lines (33 loc) · 1.92 KB
/
interface.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package store
import (
"context"
)
type Purgeable interface {
MarkCurrentHeight(height uint64)
PurgeKeys(ctx context.Context) error
}
type KVStore interface {
// Put writes to a transaction, which might be flushed from time to time. Call FlushPuts() to ensure all Put entries are properly written to the database.
Put(ctx context.Context, key, value []byte) (err error)
// FlushPuts takes any pending writes (calls to Put()), and flushes them.
FlushPuts(ctx context.Context) (err error)
// Get a given key. Returns `kvdb.ErrNotFound` if not found.
Get(ctx context.Context, key []byte) (value []byte, err error)
// Get a batch of keys. Returns `kvdb.ErrNotFound` the first time a key is not found: not finding a key is fatal and interrupts the resultset from being fetched completely. BatchGet guarantees that Iterator return results in the exact same order as keys
BatchGet(ctx context.Context, keys [][]byte) *Iterator
Scan(ctx context.Context, start, exclusiveEnd []byte, limit int, options ...ReadOption) *Iterator
Prefix(ctx context.Context, prefix []byte, limit int, options ...ReadOption) *Iterator
BatchPrefix(ctx context.Context, prefixes [][]byte, limit int, options ...ReadOption) *Iterator
BatchDelete(ctx context.Context, keys [][]byte) (err error)
// Close the underlying store engine and clear up any resources currently hold
// by this instance.
//
// Once this instance's `Close` method has been called, it's assumed to be terminated
// and cannot be reliably used to perform read/write operation on the backing engine.
Close() error
}
// ReversibleKVStore is not currently used. Was to be an optimization to avoid writing block numbers twice (to search the timeline), for stores that support reverse scans (unlike Bigtable).
type ReversibleKVStore interface {
ReverseScan(ctx context.Context, start, exclusiveEnd []byte, limit int) *Iterator
ReversePrefix(ctx context.Context, prefix []byte, limit int) *Iterator
}