Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions middleware/cache/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ import (
)

// msgp -file="manager.go" -o="manager_msgp.go" -tests=true -unexported
// Default slice limits are sized for cache payloads, with tighter field caps below.
//
//go:generate msgp -o=manager_msgp.go -tests=true -unexported
//nolint:revive // msgp requires tags on unexported fields for limit enforcement.
type item struct {
headers []cachedHeader
body []byte
ctype []byte
cencoding []byte
cacheControl []byte
expires []byte
etag []byte
headers []cachedHeader `msg:",limit=1024"` // Typical HTTP header count stays well below this.
body []byte // Cache bodies are bounded by storage policy, not msgp limits.
ctype []byte `msg:",limit=256"` // Content-Type values are short per RFCs.
cencoding []byte `msg:",limit=128"` // Content-Encoding is typically a short token.
cacheControl []byte `msg:",limit=2048"` // Cache-Control directives are bounded.
expires []byte `msg:",limit=128"` // Expires is a short HTTP-date string.
etag []byte `msg:",limit=256"` // ETags are small tokens/quoted strings.
date uint64
status int
age uint64
Expand All @@ -35,9 +37,10 @@ type item struct {
heapidx int
}

//nolint:revive // msgp requires tags on unexported fields for limit enforcement.
type cachedHeader struct {
key []byte
value []byte
key []byte `msg:",limit=512"` // Header names are small.
value []byte `msg:",limit=16384"` // Header values are bounded to reasonable sizes.
}

//msgp:ignore manager
Expand Down
Loading
Loading