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 ¶ added in v0.0.5
func MiddlewareV4(config *Config, cache CacheInterface) echo4.MiddlewareFunc
MiddlewareV4 creates a middleware to handle cache for echo V4
Types ¶
type BigCacheClient ¶ added in v0.0.6
type BigCacheClient struct {
// contains filtered or unexported fields
}
func NewBigCache ¶
func NewBigCache(config *Config) (*BigCacheClient, error)
NewBigCache creates big cache client
func (*BigCacheClient) Delete ¶ added in v0.0.6
func (c *BigCacheClient) Delete(key string) error
func (*BigCacheClient) Get ¶ added in v0.0.6
func (c *BigCacheClient) Get(key string) ([]byte, error)
func (*BigCacheClient) Reset ¶ added in v0.0.6
func (c *BigCacheClient) Reset() error
func (*BigCacheClient) Set ¶ added in v0.0.6
func (c *BigCacheClient) Set(key string, value []byte) error
func (*BigCacheClient) Type ¶ added in v0.0.8
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 ¶ added in v0.0.5
TryWriteV4 tries to write cached content if hit and return true, return false if miss
func (*Manager) WriteInfoV4 ¶ added in v0.0.9
WriteInfoV4 print cacheman information out to client
type MemcachedClient ¶ added in v0.0.7
type MemcachedClient struct {
// contains filtered or unexported fields
}
func NewMemcached ¶ added in v0.0.7
func NewMemcached(config *Config) (*MemcachedClient, error)
NewMemcached creates big cache client
func (*MemcachedClient) Delete ¶ added in v0.0.7
func (c *MemcachedClient) Delete(key string) error
func (*MemcachedClient) Get ¶ added in v0.0.7
func (c *MemcachedClient) Get(key string) ([]byte, error)
func (*MemcachedClient) Reset ¶ added in v0.0.7
func (c *MemcachedClient) Reset() error
func (*MemcachedClient) Set ¶ added in v0.0.7
func (c *MemcachedClient) Set(key string, value []byte) error
func (*MemcachedClient) Type ¶ added in v0.0.8
func (c *MemcachedClient) Type() string
type RedisClient ¶ added in v0.0.6
type RedisClient struct {
// contains filtered or unexported fields
}
func NewRedis ¶ added in v0.0.6
func NewRedis(config *Config) (*RedisClient, error)
NewRedis creates big cache client
func (*RedisClient) Delete ¶ added in v0.0.6
func (c *RedisClient) Delete(key string) error
func (*RedisClient) Reset ¶ added in v0.0.6
func (c *RedisClient) Reset() error
func (*RedisClient) Type ¶ added in v0.0.8
func (c *RedisClient) Type() string