Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache interface { Get(ctx context.Context, key []byte) (value []byte, err error) Set(ctx context.Context, key, value []byte, expireSeconds int) (err error) }
Cache defines the interface for a cache.
type CacheEntry ¶
func (*CacheEntry) Decode ¶
func (c *CacheEntry) Decode(b []byte) error
func (*CacheEntry) Encode ¶
func (c *CacheEntry) Encode() ([]byte, error)
func (*CacheEntry) Replay ¶
func (c *CacheEntry) Replay(w http.ResponseWriter) error
type CacheMiddleware ¶
type CacheMiddleware struct {
// contains filtered or unexported fields
}
func (*CacheMiddleware) Handler ¶
func (m *CacheMiddleware) Handler(next echo.HandlerFunc) echo.HandlerFunc
type Config ¶
type Config struct { // TTL time to life of the cache. TTL time.Duration `default:"1m"` // Methods methods to be cached. Methods []string `default:"[GET]"` // StatusCode method to be cached. StatusCode []int `default:"[200,404]"` // IgnoreQuery if true the Query values from the requests are ignored on // the key generation. IgnoreQuery bool // Refresh fuction called before use the cache, if true, the cache is deleted. Refresh func(r *http.Request) bool // Cache fuction called before cache a request, if false, the request is not // cached. If set Method is ignored. Cache func(r *http.Request) bool // GetKey function called to generate the key for the cache. GetKey func(r *http.Request) []byte }
Config defiens the configuration for a cache middleware.
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
func NewMemoryCache ¶
func NewMemoryCache(cache *freecache.Cache) MemoryCache
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
func NewRedisCache ¶
func NewRedisCache(cache *redis.Client) RedisCache
type ResponseRecorder ¶
type ResponseRecorder struct { http.ResponseWriter // contains filtered or unexported fields }
func NewResponseRecorder ¶
func NewResponseRecorder(w http.ResponseWriter) *ResponseRecorder
func (*ResponseRecorder) Flush ¶
func (w *ResponseRecorder) Flush()
func (*ResponseRecorder) Result ¶
func (r *ResponseRecorder) Result() *CacheEntry
func (*ResponseRecorder) WriteHeader ¶
func (w *ResponseRecorder) WriteHeader(statusCode int)
Click to show internal directories.
Click to hide internal directories.