2017-02-12 13:03:39 +03:00
|
|
|
// Copyright 2017 Microsoft. All rights reserved.
|
|
|
|
// MIT License
|
2016-07-26 04:33:43 +03:00
|
|
|
|
|
|
|
package store
|
|
|
|
|
2016-07-28 04:24:26 +03:00
|
|
|
import (
|
|
|
|
"fmt"
|
2016-12-17 05:03:03 +03:00
|
|
|
"time"
|
2016-07-28 04:24:26 +03:00
|
|
|
)
|
|
|
|
|
2016-07-26 04:33:43 +03:00
|
|
|
// KeyValueStore represents a persistent store of (key,value) pairs.
|
|
|
|
type KeyValueStore interface {
|
|
|
|
Read(key string, value interface{}) error
|
|
|
|
Write(key string, value interface{}) error
|
|
|
|
Flush() error
|
2016-11-22 00:48:03 +03:00
|
|
|
Lock(block bool) error
|
2019-01-08 04:04:39 +03:00
|
|
|
Unlock(forceUnlock bool) error
|
2016-12-17 05:03:03 +03:00
|
|
|
GetModificationTime() (time.Time, error)
|
2019-01-08 04:04:39 +03:00
|
|
|
GetLockFileModificationTime() (time.Time, error)
|
2016-07-26 04:33:43 +03:00
|
|
|
}
|
2016-07-28 04:24:26 +03:00
|
|
|
|
|
|
|
var (
|
|
|
|
// Errors returned by KeyValueStore methods.
|
2018-09-20 01:29:42 +03:00
|
|
|
ErrKeyNotFound = fmt.Errorf("key not found")
|
|
|
|
ErrStoreLocked = fmt.Errorf("store is already locked")
|
|
|
|
ErrStoreNotLocked = fmt.Errorf("store is not locked")
|
|
|
|
ErrTimeoutLockingStore = fmt.Errorf("timed out locking store")
|
|
|
|
ErrNonBlockingLockIsAlreadyLocked = fmt.Errorf("attempted to perform non-blocking lock on an already locked store")
|
2016-07-28 04:24:26 +03:00
|
|
|
)
|