1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-24 05:17:03 +00:00
Gerasimos (Makis) Maropoulos
2020-09-10 11:24:23 +03:00
parent 333be428c4
commit cf0338d342
4 changed files with 110 additions and 40 deletions

12
cache/cache.go vendored
View File

@@ -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.