-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcache_config.go
More file actions
43 lines (38 loc) · 928 Bytes
/
cache_config.go
File metadata and controls
43 lines (38 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-License-Identifier: EUPL-1.2
package api
import "time"
// CacheConfig captures the configured response cache settings for an Engine.
//
// It is intentionally small and serialisable so callers can inspect the active
// cache policy without needing to rebuild middleware state.
//
// Example:
//
// cfg := api.CacheConfig{Enabled: true, TTL: 5 * time.Minute}
type CacheConfig struct {
Enabled bool
TTL time.Duration
MaxEntries int
MaxBytes int
}
// CacheConfig returns the currently configured response cache settings for the engine.
//
// The result snapshots the Engine state at call time.
//
// Example:
//
// cfg := engine.CacheConfig()
func (e *Engine) CacheConfig() CacheConfig {
if e == nil {
return CacheConfig{}
}
cfg := CacheConfig{
TTL: e.cacheTTL,
MaxEntries: e.cacheMaxEntries,
MaxBytes: e.cacheMaxBytes,
}
if e.cacheTTL > 0 {
cfg.Enabled = true
}
return cfg
}