-
Notifications
You must be signed in to change notification settings - Fork 14
/
store.go
34 lines (29 loc) · 953 Bytes
/
store.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
// Package store defines the primitives of a simple key/value storage.
//
// Documentation Last Review: 08.10.2020
package store
// Readable is the interface for a readable store.
type Readable interface {
Get(key []byte) ([]byte, error)
}
// Writable is the interface for a writable store.
type Writable interface {
Set(key []byte, value []byte) error
// Delete deletes a given key.
// It can return an error if deleting from a read-only store
// No error is returned if the key does not exist.
Delete(key []byte) error
}
// Snapshot is a state of the store that can be read and write independently. A
// write is applied only to the snapshot reference.
type Snapshot interface {
Readable
Writable
}
// Transaction is a generic interface that store implementations can use to
// provide atomicity.
type Transaction interface {
// OnCommit adds a callback to be executed after the transaction
// successfully commits.
OnCommit(func())
}