micro/data/data.go

35 lines
617 B
Go
Raw Normal View History

2019-05-31 02:43:23 +03:00
// Package data is an interface for key-value storage.
package data
import (
"errors"
"time"
2019-06-11 19:20:52 +03:00
"github.com/micro/go-micro/options"
2019-05-31 02:43:23 +03:00
)
var (
ErrNotFound = errors.New("not found")
)
// Data is a data storage interface
type Data interface {
2019-06-11 19:20:52 +03:00
// embed options
options.Options
2019-05-31 02:43:23 +03: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 {
Key string
Value []byte
Expiration time.Duration
}