Documentation ¶
Index ¶
- Constants
- Variables
- func Cache() echo.MiddlewareFunc
- func CacheWithConfig(config CacheConfig) echo.MiddlewareFunc
- func DefaultCacheKey(prefix string, req *http.Request) string
- func DefaultCacheSkipper(c echo.Context) bool
- func DefaultCanCacheResponseSkipper(c echo.Context) bool
- type CacheConfig
- type CacheKeyFunc
- type Encoder
- type JSONEncoder
- type Marshaler
- type Metrics
- type MsgpackEncoder
- type Response
- type Unmarshaler
Constants ¶
View Source
const ( SizeKB int64 = 1024 SizeMB int64 = 1024 * SizeKB )
Variables ¶
View Source
var ( DefaultCachePrefix = "cache" DefaultCacheDuration = time.Duration(0) DefaultCacheConfig = CacheConfig{ Skipper: DefaultCacheSkipper, CanCacheResponse: DefaultCanCacheResponseSkipper, CachePrefix: DefaultCachePrefix, CacheDuration: DefaultCacheDuration, CacheKey: DefaultCacheKey, } )
Functions ¶
func CacheWithConfig ¶
func CacheWithConfig(config CacheConfig) echo.MiddlewareFunc
func DefaultCacheSkipper ¶
func DefaultCacheSkipper(c echo.Context) bool
Cache default skipper only cache GET/HEAD method and headers not contain `Range`
func DefaultCanCacheResponseSkipper ¶
func DefaultCanCacheResponseSkipper(c echo.Context) bool
Default canCacheResponse skipper will skip response cache if: - response status code not in (200, 301, 308) - response headers not contains `set-cookie`
Types ¶
type CacheConfig ¶
type CacheConfig struct { Skipper middleware.Skipper CanCacheResponse middleware.Skipper CachePrefix string CacheKey CacheKeyFunc CacheDuration time.Duration Store store.Store Encoder Encoder Metrics Metrics }
type Encoder ¶
type Encoder interface { Marshaler Unmarshaler }
Interface that marshal/unmarshal `Response`
type JSONEncoder ¶
type JSONEncoder struct{}
type Metrics ¶
type Metrics interface { // The total number of cache hits CacheHits() // The total number of cache misses CacheMisses() // The current size of the cache in bytes CacheSize(size float64) // The time it takes for the middleware to retrieve data from the cache CacheLatency(latency float64) // The total number of errors encountered while interacting with the cache CacheError() }
type MsgpackEncoder ¶
type MsgpackEncoder struct{}
type Response ¶
type Unmarshaler ¶
Click to show internal directories.
Click to hide internal directories.