23 lines
411 B
Go
23 lines
411 B
Go
package main
|
|
|
|
import "context"
|
|
|
|
type Storage struct {
|
|
driver Driver
|
|
}
|
|
|
|
type Driver interface {
|
|
Close() error
|
|
ForEach(context.Context, func(string, []byte) error) error
|
|
Get(context.Context, string) ([]byte, error)
|
|
Set(context.Context, string, []byte) error
|
|
}
|
|
|
|
func NewTestStorage() Storage {
|
|
return Storage{driver: NewTestDB()}
|
|
}
|
|
|
|
func NewStorage(driver Driver) Storage {
|
|
return Storage{driver: driver}
|
|
}
|