cache

package
v1.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(cache ICache, skipper middleware.Skipper, expirationFunc ExpirationFunc) echo.MiddlewareFunc

Types

type CacheEntry

type CacheEntry struct {
	Header     http.Header
	StatusCode int
	Body       []byte
}

func (*CacheEntry) Decode

func (c *CacheEntry) Decode(b string) error

func (*CacheEntry) Encode

func (c *CacheEntry) Encode() (string, 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 ExpirationFunc added in v1.11.0

type ExpirationFunc func() time.Duration

type ICache added in v1.9.1

type ICache interface {
	io.Closer

	Get(ctx context.Context, key string) (string, bool)
	Set(ctx context.Context, key string, data string, f ExpirationFunc) error
}

type ResponseRecorder

type ResponseRecorder struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func NewResponseRecorder

func NewResponseRecorder(w http.ResponseWriter) *ResponseRecorder

func (*ResponseRecorder) Result

func (r *ResponseRecorder) Result() *CacheEntry

func (*ResponseRecorder) Write

func (w *ResponseRecorder) Write(b []byte) (int, error)

func (*ResponseRecorder) WriteHeader

func (w *ResponseRecorder) WriteHeader(statusCode int)

type ValKey added in v1.11.0

type ValKey struct {
	// contains filtered or unexported fields
}

func NewValKey added in v1.11.0

func NewValKey(url string, ttl time.Duration) (*ValKey, error)

func (*ValKey) Close added in v1.11.0

func (c *ValKey) Close() error

func (*ValKey) Get added in v1.11.0

func (c *ValKey) Get(ctx context.Context, key string) (data string, found bool)

func (*ValKey) Set added in v1.11.0

func (c *ValKey) Set(ctx context.Context, key string, data string, expirationFunc ExpirationFunc) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL