mirror of
https://github.com/kataras/iris.git
synced 2025-12-24 05:17:03 +00:00
This commit is contained in:
12
cache/cache.go
vendored
12
cache/cache.go
vendored
@@ -34,6 +34,18 @@ import (
|
||||
"github.com/kataras/iris/v12/context"
|
||||
)
|
||||
|
||||
// WithKey sets a custom entry key for cached pages.
|
||||
// Should be prepended to the cache handler.
|
||||
//
|
||||
// Usage:
|
||||
// app.Get("/", cache.WithKey("custom-key"), cache.Handler(time.Minute), mainHandler)
|
||||
func WithKey(key string) context.Handler {
|
||||
return func(ctx *context.Context) {
|
||||
client.SetKey(ctx, key)
|
||||
ctx.Next()
|
||||
}
|
||||
}
|
||||
|
||||
// Cache accepts the cache expiration duration.
|
||||
// If the "expiration" input argument is invalid, <=2 seconds,
|
||||
// then expiration is taken by the "cache-control's maxage" header.
|
||||
|
||||
Reference in New Issue
Block a user