CacheMan was designed to be middleware for Echo for caching response from GET request for a period of time.
server := echo.New()
store, e := cacheman.NewBigCache(&cfg.Cache)
if e == nil {
server.Use(cacheman.Middleware(&cfg.Cache, store))
} server := echo.New()
store, e := cacheman.NewBigCache(&cfg.Cache)
if e == nil {
server.Use(cacheman.MiddlewareV4(&cfg.Cache, store))
}- BigCache - allegro/bigcache
- Memcache - bradfitz/gomemcache
- Redis - go-redis/redis
Just implement this interface and pass it into cacheman.Middleware.
type CacheInterface interface {
Get(key string) ([]byte, error)
Set(key string, value []byte) error
Delete(key string) error
Reset() error
Type() string
}Set to true to enable cacheman or false to disable. Default is false,
Set to true to print out cacheman log or falst to make cacheman quiet. Default is false,
Cache entry life span in duration format. For example, 5m for 5 minutes, 1d for 1 day. Default is 1d.
Paths to be cached. Path with embedded variables like /user/:id is supported. Regular expression string is also supported, /.* to cache every path. Default is []string{},
Paths to be excluded from cache. ExcludedPaths has higher priority than Paths. Default is []string{},
Custom headers added into returned cache. Default is map[string]string{},
URI to request cacheman information. Send GET request to this path to see cacheman information. Make it empty to disable it. Default is <empty>.
URI to purge cache. Send PURGE request to this path to empty cache. Make it empty to disable it. Default is <empty>.