Documentation ¶
Overview ¶
Package cache contains abstractions and implementations for a cache backend.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound is returned when an key is not found. ErrNotFound = errors.New("key not found") )
Functions ¶
func Register ¶
Register registers a new backend by scheme. It will panic if multiple backends are registered under the same scheme.
func ValidateKey ¶
ValidateKey returns an error if key is invalid.
Types ¶
type Backend ¶
type Backend interface { // Ping returns an error if offline. Ping(context.Context) error // Begin starts a new Transation. Begin(context.Context) (Transaction, error) // Close closes the backend. Close() error }
Backend defines the abstract backend.
type Transaction ¶
type Transaction interface { // Commit commits the transaction. Commit() error // Rollback aborts the transaction. Rollback() error // Flush deletes all stored data. Flush() error // Get retrieves a key. May return ErrNotFound. Get(key string) ([]byte, error) // Set sets a value for key. Set(key string, val []byte, exp time.Time) error // Del deletes a key. May return ErrNotFound. Del(key string) error }
Transaction is a transaction.
Click to show internal directories.
Click to hide internal directories.