This section is empty.


This section is empty.


This section is empty.


type CacheMiddleware

type CacheMiddleware struct {
	// contains filtered or unexported fields

CacheMiddleware for monitoror * * We need two types of Cache. * - UpstreamCache : serves as a circuit breaker to answer before executing the request. (By default, short TTL) * - DownstreamCache : serves as backup to answer the old result in case of service timeout. (By default, long TTL) * * UpstreamCache must be implemented on some routes only (and with variable expiration). * He is implemented as a decorator on the handler of each route * * DownstreamCache should be used instead of a timeout response. * So we look at the cache in the global error handler (see handlers/errors.go) * * To fill both store at the same time, I implemented a store wrapper that performs every actions on both store

func NewCacheMiddleware

func NewCacheMiddleware(store cache.Store, downstreamDefaultExpiration, upstreamDefaultExpiration time.Duration) *CacheMiddleware

NewCacheMiddleware used config to instantiate CacheMiddleware

func (*CacheMiddleware) DownstreamStoreMiddleware

func (cm *CacheMiddleware) DownstreamStoreMiddleware() echo.MiddlewareFunc

DownstreamStoreMiddleware Provide Downstream Store to all route. Used when route return timeout error

func (*CacheMiddleware) UpstreamCacheHandler

func (cm *CacheMiddleware) UpstreamCacheHandler(handle echo.HandlerFunc) echo.HandlerFunc

UpstreamCacheHandler return the cached response if he finds it in the store. (Decorator Handlers)

func (*CacheMiddleware) UpstreamCacheHandlerWithExpiration

func (cm *CacheMiddleware) UpstreamCacheHandlerWithExpiration(expire time.Duration, handle echo.HandlerFunc) echo.HandlerFunc

UpstreamCacheHandlerWithExpiration return the cached response if he finds it in the store. (Decorator Handlers)

Source Files