Home / File/ cache_test.go — fiber Source File

cache_test.go — fiber Source File

Architecture documentation for cache_test.go, a go file in the fiber codebase. 1 imports, 0 dependents.

File go FiberMiddleware Caching 1 imports 103 functions 15 classes

Entity Profile

Dependency Diagram

graph LR
  8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"]
  c0b86961_3ef1_0168_52fc_98627566ed27["bytes"]
  8453a087_9678_fe96_1b20_2d125b6f8656 --> c0b86961_3ef1_0168_52fc_98627566ed27
  style 8453a087_9678_fe96_1b20_2d125b6f8656 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// Special thanks to @codemicro for moving this to fiber core
// Original middleware: github.com/codemicro/fiber-cache
package cache

import (
	"bytes"
	"context"
	"errors"
	"fmt"
	"io"
	"math"
	"net/http"
	"net/http/httptest"
	"os"
	"strconv"
	"strings"
	"sync"
	"sync/atomic"
	"testing"
	"time"

	"github.com/gofiber/fiber/v3"
	"github.com/gofiber/fiber/v3/internal/storage/memory"
	"github.com/gofiber/fiber/v3/middleware/etag"
	"github.com/gofiber/utils/v2"
	"github.com/stretchr/testify/require"
	"github.com/valyala/fasthttp"
)

type failingCacheStorage struct {
	data map[string][]byte
	errs map[string]error
	mu   sync.RWMutex
}

type mutatingStorage struct {
	data   map[string][]byte
	mutate func(key string, value []byte) []byte
}

func newFailingCacheStorage() *failingCacheStorage {
	return &failingCacheStorage{
		data: make(map[string][]byte),
		errs: make(map[string]error),
	}
}

func newMutatingStorage(mutate func(key string, value []byte) []byte) *mutatingStorage {
	return &mutatingStorage{
		data:   make(map[string][]byte),
		mutate: mutate,
	}
}

func (s *mutatingStorage) GetWithContext(_ context.Context, key string) ([]byte, error) {
	return s.Get(key)
}

func (s *mutatingStorage) Get(key string) ([]byte, error) {
	if value, ok := s.data[key]; ok {
// ... (5034 more lines)

Subdomains

Functions

Dependencies

  • bytes

Frequently Asked Questions

What does cache_test.go do?
cache_test.go is a source file in the fiber codebase, written in go. It belongs to the FiberMiddleware domain, Caching subdomain.
What functions are defined in cache_test.go?
cache_test.go defines 103 function(s): Benchmark_Cache, Benchmark_Cache_AdditionalHeaders, Benchmark_Cache_MaxSize, Benchmark_Cache_Miss, Benchmark_Cache_Storage, TestCacheAgeHeader, TestCacheAllowsAuthorizationWithRevalidateDirectives, TestCacheAllowsSharedCacheWithAuthorization, TestCacheBypassesExistingEntryForAuthorization, TestCacheCleanupPropagatesRequestContextToDelete, and 93 more.
What does cache_test.go depend on?
cache_test.go imports 1 module(s): bytes.
Where is cache_test.go in the architecture?
cache_test.go is located at middleware/cache/cache_test.go (domain: FiberMiddleware, subdomain: Caching, directory: middleware/cache).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free