2019-06-12 08:46:20 +02:00
|
|
|
// Package store is an interface for distribute data storage.
|
|
|
|
package store
|
2019-05-31 01:43:23 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"time"
|
2019-06-11 18:20:52 +02:00
|
|
|
|
|
|
|
"github.com/micro/go-micro/options"
|
2019-05-31 01:43:23 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
ErrNotFound = errors.New("not found")
|
|
|
|
)
|
|
|
|
|
2019-06-12 08:46:20 +02:00
|
|
|
// Store is a data storage interface
|
|
|
|
type Store interface {
|
2019-06-11 18:20:52 +02:00
|
|
|
// embed options
|
|
|
|
options.Options
|
2019-05-31 01:43:23 +02:00
|
|
|
// Dump the known records
|
|
|
|
Dump() ([]*Record, error)
|
|
|
|
// Read a record with key
|
|
|
|
Read(key string) (*Record, error)
|
|
|
|
// Write a record
|
|
|
|
Write(r *Record) error
|
|
|
|
// Delete a record with key
|
|
|
|
Delete(key string) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// Record represents a data record
|
|
|
|
type Record struct {
|
2019-06-11 18:49:34 +02:00
|
|
|
Key string
|
|
|
|
Value []byte
|
|
|
|
Expiry time.Duration
|
2019-05-31 01:43:23 +02:00
|
|
|
}
|