2019-06-12 07:46:20 +01:00
|
|
|
// Package store is an interface for distribute data storage.
|
|
|
|
package store
|
2019-05-31 00:43:23 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"time"
|
2019-06-11 17:20:52 +01:00
|
|
|
|
2019-06-12 12:45:42 +01:00
|
|
|
"github.com/micro/go-micro/config/options"
|
2019-05-31 00:43:23 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
ErrNotFound = errors.New("not found")
|
|
|
|
)
|
|
|
|
|
2019-06-12 07:46:20 +01:00
|
|
|
// Store is a data storage interface
|
|
|
|
type Store interface {
|
2019-06-11 17:20:52 +01:00
|
|
|
// embed options
|
|
|
|
options.Options
|
2019-10-03 09:56:25 +01:00
|
|
|
// Sync all the known records
|
|
|
|
Sync() ([]*Record, error)
|
2019-05-31 00:43:23 +01:00
|
|
|
// Read a record with key
|
2019-10-11 14:08:50 +01:00
|
|
|
Read(keys ...string) ([]*Record, error)
|
2019-05-31 00:43:23 +01:00
|
|
|
// Write a record
|
2019-10-11 14:08:50 +01:00
|
|
|
Write(recs ...*Record) error
|
2019-05-31 00:43:23 +01:00
|
|
|
// Delete a record with key
|
2019-10-11 14:08:50 +01:00
|
|
|
Delete(keys ...string) error
|
2019-05-31 00:43:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Record represents a data record
|
|
|
|
type Record struct {
|
2019-06-11 17:49:34 +01:00
|
|
|
Key string
|
|
|
|
Value []byte
|
|
|
|
Expiry time.Duration
|
2019-05-31 00:43:23 +01:00
|
|
|
}
|