mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-19 21:45:17 +00:00
M3O SDK Concept
This commit is contained in:
50
store/keyvalue/keyvalue.go
Normal file
50
store/keyvalue/keyvalue.go
Normal file
@@ -0,0 +1,50 @@
|
||||
// Package keyvalue provides a key value store
|
||||
package keyvalue
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrRecordNotFound is returned when trying to read a record which does not exist
|
||||
ErrRecordNotFound = errors.New("Record not found")
|
||||
)
|
||||
|
||||
// NewClient returns an RPC client for the KeyValue store. It will communicate with the M3O KeyValue
|
||||
// service.
|
||||
func NewClient() Store {
|
||||
|
||||
}
|
||||
|
||||
// NewMock returns an in-memory mock for the KeyValue store. It is designed for use in tests.
|
||||
func NewMock() Store {
|
||||
|
||||
}
|
||||
|
||||
// Store is an interface providing key value storage
|
||||
type Store interface {
|
||||
Read(key string) (Record, error)
|
||||
List(ListOptions) ([]Record, error)
|
||||
Write(key, value string, opts WriteOptions) error
|
||||
Delete(key string) error
|
||||
}
|
||||
|
||||
// ListOptions are used to filter results of the list operation
|
||||
type ListOptions struct {
|
||||
// Prefix limits the results to those where the key has the given prefix
|
||||
Prefix string
|
||||
}
|
||||
|
||||
// WriteOptions are provided when writing a file to the store
|
||||
type WriteOptions struct {
|
||||
// Expiry sets the time at which the file should be deleted
|
||||
Expiry time.Time
|
||||
}
|
||||
|
||||
// Record returned from the key value store
|
||||
type Record struct {
|
||||
Key string
|
||||
Value string
|
||||
Expiry time.Time
|
||||
}
|
||||
Reference in New Issue
Block a user