gitee.com/liuxuezhan/go-micro-v1.18.0@v1.0.0/store/store.go (about)

     1  // Package store is an interface for distribute data storage.
     2  package store
     3  
     4  import (
     5  	"errors"
     6  	"time"
     7  )
     8  
     9  var (
    10  	// ErrNotFound is returned when a Read key doesn't exist
    11  	ErrNotFound = errors.New("not found")
    12  )
    13  
    14  // Store is a data storage interface
    15  type Store interface {
    16  	// List all the known records
    17  	List() ([]*Record, error)
    18  	// Read records with keys
    19  	Read(key ...string) ([]*Record, error)
    20  	// Write records
    21  	Write(rec ...*Record) error
    22  	// Delete records with keys
    23  	Delete(key ...string) error
    24  }
    25  
    26  // Record represents a data record
    27  type Record struct {
    28  	Key    string
    29  	Value  []byte
    30  	Expiry time.Duration
    31  }