mirror of
https://github.com/jimeh/ozu.io.git
synced 2026-02-19 08:06:39 +00:00
Noramlize Store interface
Instead of exposing a key/value get/set style interface, design the interface around the actions that are actually required. This is a first step towards supporting adding a Store to support Google Cloud's Datastore.
This commit is contained in:
@@ -1,10 +1,23 @@
|
||||
package storage
|
||||
|
||||
// Store defines a standard interface for storage.
|
||||
import "errors"
|
||||
|
||||
// ErrNotFound is the default error message when data is not found.
|
||||
var ErrNotFound = errors.New("not found")
|
||||
|
||||
// Store defines a standard interface for storage
|
||||
type Store interface {
|
||||
Close() error
|
||||
Get([]byte) ([]byte, error)
|
||||
Set([]byte, []byte) error
|
||||
Delete([]byte) error
|
||||
Create(UID []byte, URL []byte) (*Record, error)
|
||||
FindByUID(UID []byte) (*Record, error)
|
||||
FindByURL(URL []byte) (*Record, error)
|
||||
DeleteByUID(UID []byte) (*Record, error)
|
||||
DeleteByURL(URL []byte) (*Record, error)
|
||||
NextSequence() (int, error)
|
||||
}
|
||||
|
||||
// Record provides a standard way to refer to a shortened URL.
|
||||
type Record struct {
|
||||
UID []byte
|
||||
URL []byte
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user