Test_Cache_MaxBytesSizes() — fiber Function Reference
Architecture documentation for the Test_Cache_MaxBytesSizes() function in cache_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 42fcb8e0_c98e_062d_214f_ac044cda848a["Test_Cache_MaxBytesSizes()"] 8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"] 42fcb8e0_c98e_062d_214f_ac044cda848a -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656 d85d9be6_add5_aae9_e8ed_6409b730b1bf["stableAscendingExpiration()"] 42fcb8e0_c98e_062d_214f_ac044cda848a -->|calls| d85d9be6_add5_aae9_e8ed_6409b730b1bf style 42fcb8e0_c98e_062d_214f_ac044cda848a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/cache/cache_test.go lines 1441–1473
func Test_Cache_MaxBytesSizes(t *testing.T) {
t.Parallel()
app := fiber.New()
app.Use(New(Config{
MaxBytes: 7,
ExpirationGenerator: stableAscendingExpiration(),
}))
app.Get("/*", func(c fiber.Ctx) error {
path := c.RequestCtx().URI().LastPathSegment()
size, err := strconv.Atoi(string(path))
require.NoError(t, err)
return c.Send(make([]byte, size))
})
cases := [][]string{
{"/1", cacheMiss},
{"/2", cacheMiss},
{"/3", cacheMiss},
{"/4", cacheMiss}, // 1+2+3+4 > 7 => 1,2 are evicted now
{"/3", cacheHit},
{"/1", cacheMiss},
{"/2", cacheMiss},
{"/8", cacheUnreachable}, // too big to cache -> unreachable
}
for idx, tcase := range cases {
rsp, err := app.Test(httptest.NewRequest(fiber.MethodGet, tcase[0], http.NoBody))
require.NoError(t, err)
require.Equal(t, tcase[1], rsp.Header.Get("X-Cache"), "Case %v", idx)
}
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_Cache_MaxBytesSizes() do?
Test_Cache_MaxBytesSizes() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is Test_Cache_MaxBytesSizes() defined?
Test_Cache_MaxBytesSizes() is defined in middleware/cache/cache_test.go at line 1441.
What does Test_Cache_MaxBytesSizes() call?
Test_Cache_MaxBytesSizes() calls 1 function(s): stableAscendingExpiration.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free