-
Notifications
You must be signed in to change notification settings - Fork 243
/
Copy pathstore.go
31 lines (27 loc) · 954 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
// Copyright 2017 Microsoft. All rights reserved.
// MIT License
package store
import (
"fmt"
"time"
)
// KeyValueStore represents a persistent store of (key,value) pairs.
type KeyValueStore interface {
Exists() bool
Read(key string, value interface{}) error
Write(key string, value interface{}) error
Flush() error
Lock(timeout time.Duration) error
Unlock() error
GetModificationTime() (time.Time, error)
Remove()
}
var (
// Errors returned by KeyValueStore methods.
ErrKeyNotFound = fmt.Errorf("key not found")
ErrStoreLocked = fmt.Errorf("store is already locked")
ErrStoreNotLocked = fmt.Errorf("store is not locked")
ErrStoreEmpty = fmt.Errorf("store is empty")
ErrTimeoutLockingStore = fmt.Errorf("timed out locking store")
ErrNonBlockingLockIsAlreadyLocked = fmt.Errorf("attempted to perform non-blocking lock on an already locked store")
)