Documentation ¶
Overview ¶
Package store hosts a Store interface and its implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrKeyNotFound is the error returned if key is not found in Store. ErrKeyNotFound = fmt.Errorf("key is not found") )
Functions ¶
func ValidateKey ¶
ValidateKey returns an error if the given key does not meet the requirement of the key format and length.
Types ¶
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore is an implementation of the Store interface which stores data in files.
type Store ¶
type Store interface { // key must contain one or more characters in [A-Za-z0-9] // Write writes data with key. Write(key string, data []byte) error // Read retrieves data with key // Read must return ErrKeyNotFound if key is not found. Read(key string) ([]byte, error) // Delete deletes data by key // Delete must not return error if key does not exist Delete(key string) error // List lists all existing keys. List() ([]string, error) }
Store provides the interface for storing keyed data. Store must be thread-safe
func NewFileStore ¶
func NewFileStore(path string, fs utilfs.Filesystem) (Store, error)
NewFileStore returns an instance of FileStore.
Click to show internal directories.
Click to hide internal directories.