cache_test.go — fiber Source File
Architecture documentation for cache_test.go, a go file in the fiber codebase. 1 imports, 0 dependents.
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)
Domain
Subdomains
Functions
- Benchmark_Cache()
- Benchmark_Cache_AdditionalHeaders()
- Benchmark_Cache_MaxSize()
- Benchmark_Cache_Miss()
- Benchmark_Cache_Storage()
- TestCacheAgeHeader()
- TestCacheAllowsAuthorizationWithRevalidateDirectives()
- TestCacheAllowsSharedCacheWithAuthorization()
- TestCacheBypassesExistingEntryForAuthorization()
- TestCacheCleanupPropagatesRequestContextToDelete()
- TestCacheEvictionPropagatesRequestContextToDelete()
- TestCacheSeparatesAuthorizationValues()
- TestCacheSkipsAuthorizationByDefault()
- TestCacheStorageDeleteError()
- TestCacheStorageGetError()
- TestCacheStorageOperationsObserveRequestContext()
- TestCacheStorageSetError()
- TestCacheUpstreamAge()
- Test_AdditionalE2EResponseHeaders()
- Test_AllowsSharedCache()
- Test_Cache()
- Test_CacheAgeHeaderIsCappedAtMaxDeltaSeconds()
- Test_CacheAllowsSharedCacheMustRevalidateWithAuthorization()
- Test_CacheAllowsSharedCacheProxyRevalidateWithAuthorization()
- Test_CacheClampsFutureStoredDate()
- Test_CacheClampsInvalidStoredDate()
- Test_CacheControlNotOverwritten()
- Test_CacheDateAndAgeHandling()
- Test_CacheExpiresFutureAllowsCaching()
- Test_CacheExpiresPastPreventsCaching()
- Test_CacheHeader()
- Test_CacheHeuristicFreshnessAddsWarning113()
- Test_CacheHeuristicFreshnessAddsWarning113AfterThreshold()
- Test_CacheInvalidExpiresStoredAsStale()
- Test_CacheInvalidation()
- Test_CacheInvalidation_noCacheEntry()
- Test_CacheInvalidation_removeFromHeap()
- Test_CacheMaxAgeDirective()
- Test_CacheMaxStaleRespectsMustRevalidate()
- Test_CacheMaxStaleRespectsProxyRevalidateSharedAuth()
- Test_CacheMaxStaleServesStaleResponse()
- Test_CacheMinFreshForcesRevalidation()
- Test_CacheNoCacheDirective()
- Test_CacheNoCacheDirectiveOverridesExistingEntry()
- Test_CacheNoStoreDirective()
- Test_CacheOnlyIfCachedMiss()
- Test_CacheOnlyIfCachedStaleNotServed()
- Test_CachePermanentRedirectCached()
- Test_CachePreservesCacheControlHeaders()
- Test_CachePrivateDirective()
- Test_CachePrivateDirectiveInvalidatesExistingEntry()
- Test_CachePrivateDirectiveWithAuthorization()
- Test_CacheRequestMaxAgeRevalidates()
- Test_CacheRespectsUpstreamAgeForFreshness()
- Test_CacheSMaxAgeOverridesMaxAgeWhenLonger()
- Test_CacheSMaxAgeOverridesMaxAgeWhenShorter()
- Test_CacheStaleResponseAddsWarning110()
- Test_CacheStorage_CustomHeaders()
- Test_CacheVarySeparatesVariants()
- Test_CacheVaryStarUncacheable()
- Test_Cache_CacheControl()
- Test_Cache_CacheControlCombinations()
- Test_Cache_CacheControl_Disabled()
- Test_Cache_ConfigurationAndResponseHandling()
- Test_Cache_CustomNext()
- Test_Cache_DateAndCacheControl()
- Test_Cache_Expired()
- Test_Cache_Get()
- Test_Cache_HelperFunctions()
- Test_Cache_Invalid_Expiration()
- Test_Cache_MaxBytesOrder()
- Test_Cache_MaxBytesSizes()
- Test_Cache_MaxBytes_ConcurrencyAndRaceConditions()
- Test_Cache_MaxBytes_DeletionFailureRestoresTracking()
- Test_Cache_MaxBytes_InsufficientSpace()
- Test_Cache_NothingToCache()
- Test_Cache_Post()
- Test_Cache_RequestResponseDirectives()
- Test_Cache_RevalidationWithMaxBytes()
- Test_Cache_UncacheableStatusCodes()
- Test_Cache_VaryAndAuth()
- Test_Cache_WithETagAndNoCacheRequestDirective()
- Test_Cache_WithHead()
- Test_Cache_WithHeadThenGet()
- Test_Cache_WithNoCacheRequestDirective()
- Test_Cache_WithNoStoreRequestDirective()
- Test_Cache_WithSeveralRequests()
- Test_CustomCacheHeader()
- Test_CustomExpiration()
- Test_CustomKey()
- Test_ParseMaxAge()
- Test_RequestPragmaNoCacheTriggersMiss()
- Test_parseCacheControlDirectives_QuotedStrings()
- Test_unquoteCacheDirective()
- canceledContextWithMarker()
- contextRecordFrom()
- contextWithMarker()
- key()
- newContextRecorderStorage()
- newFailingCacheStorage()
- newMutatingStorage()
- setResponseDate()
- stableAscendingExpiration()
Classes
Types
Dependencies
- bytes
Source
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