Change the store interface to remove variadic args (#1095)
This commit is contained in:
@@ -20,11 +20,11 @@ type Store interface {
|
||||
// List all the known records
|
||||
List() ([]*Record, error)
|
||||
// Read records with keys
|
||||
Read(key ...string) ([]*Record, error)
|
||||
Read(key string, opts ...ReadOption) ([]*Record, error)
|
||||
// Write records
|
||||
Write(rec ...*Record) error
|
||||
Write(*Record) error
|
||||
// Delete records with keys
|
||||
Delete(key ...string) error
|
||||
Delete(key string) error
|
||||
}
|
||||
|
||||
// Record represents a data record
|
||||
@@ -34,6 +34,13 @@ type Record struct {
|
||||
Expiry time.Duration
|
||||
}
|
||||
|
||||
type ReadOptions struct {
|
||||
// Read key as a prefix
|
||||
Prefix bool
|
||||
}
|
||||
|
||||
type ReadOption func(o *ReadOptions)
|
||||
|
||||
type noop struct{}
|
||||
|
||||
func (n *noop) Init(...Option) error {
|
||||
@@ -44,14 +51,14 @@ func (n *noop) List() ([]*Record, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (n *noop) Read(key ...string) ([]*Record, error) {
|
||||
func (n *noop) Read(key string, opts ...ReadOption) ([]*Record, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (n *noop) Write(rec ...*Record) error {
|
||||
func (n *noop) Write(rec *Record) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *noop) Delete(key ...string) error {
|
||||
func (n *noop) Delete(key string) error {
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user