Documentation ¶
Index ¶
- Constants
- func MiddlewareV4(config *Config, cache CacheInterface) echo4.MiddlewareFunc
- type BigCacheClient
- type CacheInterface
- type Config
- type Content
- type Interceptor
- type Manager
- func (c *Manager) Get(path string) ([]byte, bool)
- func (c *Manager) Log(msg string)
- func (c *Manager) Purge() error
- func (c *Manager) Set(path string, b []byte) error
- func (c *Manager) TestPath(path string) bool
- func (c *Manager) TryWriteV4(ctx echo4.Context) bool
- func (c *Manager) WriteInfoV4(ctx echo4.Context)
- type MemcachedClient
- type RedisClient
Constants ¶
const ( // HealthCheckUntested tells that operation has not been tested HealthCheckUntested string = "untested" // HealthCheckFailed tells that operation has failed the test HealthCheckFailed string = "failed" // HealthCheckPassed tells that operation has passed the test HealthCheckPassed string = "passed" )
Variables ¶
This section is empty.
Functions ¶
func MiddlewareV4 ¶
func MiddlewareV4(config *Config, cache CacheInterface) echo4.MiddlewareFunc
MiddlewareV4 creates a middleware to handle cache for echo V4
Types ¶
type BigCacheClient ¶
type BigCacheClient struct {
// contains filtered or unexported fields
}
func NewBigCache ¶
func NewBigCache(config *Config) (*BigCacheClient, error)
NewBigCache creates big cache client
func (*BigCacheClient) Delete ¶
func (c *BigCacheClient) Delete(key string) error
func (*BigCacheClient) Reset ¶
func (c *BigCacheClient) Reset() error
func (*BigCacheClient) Type ¶
func (c *BigCacheClient) Type() string
type CacheInterface ¶
type CacheInterface interface { Get(key string) ([]byte, error) Set(key string, value []byte) error Delete(key string) error Reset() error Type() string }
CacheInterface defines interface for cache
type Config ¶
type Config struct { // Enabled to enable/disable cacheman Enabled bool // Verbose allow activities of cacheman to be display on console Verbose bool // TTL is age of cache entry in duration format, e.g. 1d for one day TTL string // Paths that will be cached Paths []string // ExcludedPaths are paths to be excluded from cache ExcludedPaths []string // AdditionalHeaders are injected in return cache AdditionalHeaders map[string]string // Server is cache server in host:port format Server string // Password is credential for accessing cache service Password string // Database is database name or index Database interface{} // CacheInfoPath is URI to request cache information CacheInfoPath string // PurgePath is URI to purge all content in cache PurgePath string // Namespace to be automatically added into cache key Namespace string }
Config for cacheman
type Content ¶
type Content struct { Status int `json:"status"` Headers http.Header `json:"headers"` Content string `json:"content"` }
Content is cached content
type Interceptor ¶
type Interceptor struct {
// contains filtered or unexported fields
}
Interceptor is response interceptor
func NewInterceptor ¶
func NewInterceptor(writer http.ResponseWriter) *Interceptor
NewInterceptor creates a new response interceptor
func (*Interceptor) Content ¶
func (c *Interceptor) Content() []byte
Content returns the captured content
func (*Interceptor) Header ¶
func (c *Interceptor) Header() http.Header
Header returns response header
func (*Interceptor) Write ¶
func (c *Interceptor) Write(b []byte) (int, error)
Write writes out the content. Automatically writes out the header if it has not been written out.
func (*Interceptor) WriteHeader ¶
func (c *Interceptor) WriteHeader(statusCode int)
WriteHeader writes out the header with given status code
type Manager ¶
type Manager struct { Enabled bool Verbose bool Cache CacheInterface Routes []string ExcludedRoutes []string RouteCount int ExcludedRouteCount int ComparableRoutes []*regexp.Regexp ComparableExcludedRoutes []*regexp.Regexp AdditionalHeaders map[string]string Namespace string }
Manager is cache manager
func NewCacheManager ¶
func NewCacheManager(conf *Config, cache CacheInterface) *Manager
NewCacheManager creates a cache manager
func (*Manager) TryWriteV4 ¶
TryWriteV4 tries to write cached content if hit and return true, return false if miss
func (*Manager) WriteInfoV4 ¶
WriteInfoV4 print cacheman information out to client
type MemcachedClient ¶
type MemcachedClient struct {
// contains filtered or unexported fields
}
func NewMemcached ¶
func NewMemcached(config *Config) (*MemcachedClient, error)
NewMemcached creates big cache client
func (*MemcachedClient) Delete ¶
func (c *MemcachedClient) Delete(key string) error
func (*MemcachedClient) Reset ¶
func (c *MemcachedClient) Reset() error
func (*MemcachedClient) Type ¶
func (c *MemcachedClient) Type() string
type RedisClient ¶
type RedisClient struct {
// contains filtered or unexported fields
}
func NewRedis ¶
func NewRedis(config *Config) (*RedisClient, error)
NewRedis creates big cache client
func (*RedisClient) Delete ¶
func (c *RedisClient) Delete(key string) error
func (*RedisClient) Reset ¶
func (c *RedisClient) Reset() error
func (*RedisClient) Type ¶
func (c *RedisClient) Type() string