Home / Function/ Test_Cache_MaxBytesOrder() — fiber Function Reference

Test_Cache_MaxBytesOrder() — fiber Function Reference

Architecture documentation for the Test_Cache_MaxBytesOrder() function in cache_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  31dd5852_b2cf_8dce_017d_cea1827a4853["Test_Cache_MaxBytesOrder()"]
  8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"]
  31dd5852_b2cf_8dce_017d_cea1827a4853 -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656
  d85d9be6_add5_aae9_e8ed_6409b730b1bf["stableAscendingExpiration()"]
  31dd5852_b2cf_8dce_017d_cea1827a4853 -->|calls| d85d9be6_add5_aae9_e8ed_6409b730b1bf
  style 31dd5852_b2cf_8dce_017d_cea1827a4853 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/cache/cache_test.go lines 1405–1439

func Test_Cache_MaxBytesOrder(t *testing.T) {
	t.Parallel()
	app := fiber.New()
	app.Use(New(Config{
		MaxBytes:            2,
		ExpirationGenerator: stableAscendingExpiration(),
	}))

	app.Get("/*", func(c fiber.Ctx) error {
		return c.SendString("1")
	})

	cases := [][]string{
		// Insert a, b into cache of size 2 bytes (responses are 1 byte)
		{"/a", cacheMiss},
		{"/b", cacheMiss},
		{"/a", cacheHit},
		{"/b", cacheHit},
		// Add c -> a evicted
		{"/c", cacheMiss},
		{"/b", cacheHit},
		// Add a again -> b evicted
		{"/a", cacheMiss},
		{"/c", cacheHit},
		// Add b -> c evicted
		{"/b", cacheMiss},
		{"/c", cacheMiss},
	}

	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)
	}
}

Subdomains

Frequently Asked Questions

What does Test_Cache_MaxBytesOrder() do?
Test_Cache_MaxBytesOrder() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is Test_Cache_MaxBytesOrder() defined?
Test_Cache_MaxBytesOrder() is defined in middleware/cache/cache_test.go at line 1405.
What does Test_Cache_MaxBytesOrder() call?
Test_Cache_MaxBytesOrder() 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