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)
(key string)
| 40 | // Usage: |
| 41 | // app.Get("/", cache.WithKey("custom-key"), cache.Handler(time.Minute), mainHandler) |
| 42 | func WithKey(key string) context.Handler { |
| 43 | return func(ctx *context.Context) { |
| 44 | client.SetKey(ctx, key) |
| 45 | ctx.Next() |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | // DefaultMaxAge is a function which returns the |
| 50 | // `context#MaxAge` as time.Duration. |