Documentation ¶
Overview ¶
Package cache provides unified access to cache backends.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Normalize ¶
Normalize returns valid cache key. It can automatically detect prefixed/non-prefixed cache key and format the key properly.
func NormalizeMulti ¶
NormalizeMulti is batch version of Normalize.
Types ¶
type Fetcher ¶
type Fetcher interface { Fetch(key string, r *http.Request) ([]byte, *FetchInfo, error) FetchMulti(keys []string, r *http.Request) (map[string][]byte, map[string]*FetchInfo, error) }
Fetcher is the interface for getting cache data from remote backend based on given key(s).
type Normalizer ¶
Normalizer is the interface for normalizing cache key
type Provider ¶
type Provider interface { Storage Normalizer Namespace() string }
Provider wraps Storage interface with additional functionalities.
func NewProvider ¶
NewProvider returns Provider from a Storage and prefix.
type Reader ¶
type Reader interface { Name() string Read(key string) ([]byte, error) ReadMulti(keys []string) (map[string][]byte, error) }
Reader is the interface for cache backend implementation for reading cache data.
type RemoteOption ¶
type RemoteOption struct { Transport http.RoundTripper Timeout time.Duration Resolver Resolver }
RemoteOption is the configuration option for the RemoteProvider.
type RemoteProvider ¶
RemoteProvider enhances Provider with remote functionalities.
func NewRemoteProvider ¶
func NewRemoteProvider(p Provider, opt RemoteOption) RemoteProvider
NewRemoteProvider returns RemoteProvider from a Provider and RemoteOption.