Test_CacheHeuristicFreshnessAddsWarning113AfterThreshold() — fiber Function Reference
Architecture documentation for the Test_CacheHeuristicFreshnessAddsWarning113AfterThreshold() function in cache_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 97d1752a_3e98_f5e6_a792_e22705d64bbb["Test_CacheHeuristicFreshnessAddsWarning113AfterThreshold()"] 8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"] 97d1752a_3e98_f5e6_a792_e22705d64bbb -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656 a76eea88_fb7a_293c_1e6a_ee5f49e6d6ae["newMutatingStorage()"] 97d1752a_3e98_f5e6_a792_e22705d64bbb -->|calls| a76eea88_fb7a_293c_1e6a_ee5f49e6d6ae style 97d1752a_3e98_f5e6_a792_e22705d64bbb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/cache/cache_test.go lines 2399–2465
func Test_CacheHeuristicFreshnessAddsWarning113AfterThreshold(t *testing.T) {
t.Parallel()
storage := newMutatingStorage(func(key string, val []byte) []byte {
if strings.HasSuffix(key, "_body") {
return val
}
var it item
if _, err := it.UnmarshalMsg(val); err != nil {
return val
}
oldDate := time.Now().Add(-25 * time.Hour).UTC()
sec := oldDate.Unix()
if sec < 0 {
sec = 0
}
it.date = uint64(sec) //nolint:gosec // safe: sec is clamped to non-negative range
future := time.Now().Add(48 * time.Hour).UTC()
expSec := future.Unix()
if expSec < 0 {
expSec = 0
}
it.exp = uint64(expSec) //nolint:gosec // safe: expSec is clamped to non-negative range
it.ttl = uint64((48 * time.Hour) / time.Second)
updated, err := it.MarshalMsg(nil)
if err != nil {
return val
}
return updated
})
app := fiber.New()
app.Use(New(Config{
Expiration: 2 * time.Second,
Storage: storage,
}))
var count int
app.Get("/", func(c fiber.Ctx) error {
count++
return c.SendString("body" + strconv.Itoa(count))
})
resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheMiss, resp.Header.Get("X-Cache"))
resp, err = app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheHit, resp.Header.Get("X-Cache"))
warnings := resp.Header.Values(fiber.HeaderWarning)
require.NotEmpty(t, warnings)
found := false
for _, w := range warnings {
if strings.Contains(w, "113") {
found = true
break
}
}
require.True(t, found, "warning 113 not found in %v", warnings)
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does Test_CacheHeuristicFreshnessAddsWarning113AfterThreshold() do?
Test_CacheHeuristicFreshnessAddsWarning113AfterThreshold() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is Test_CacheHeuristicFreshnessAddsWarning113AfterThreshold() defined?
Test_CacheHeuristicFreshnessAddsWarning113AfterThreshold() is defined in middleware/cache/cache_test.go at line 2399.
What does Test_CacheHeuristicFreshnessAddsWarning113AfterThreshold() call?
Test_CacheHeuristicFreshnessAddsWarning113AfterThreshold() calls 1 function(s): newMutatingStorage.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free