proxy_cache

package
v0.1.0-rc.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStoreIntentAlreadyConsumed = errors.New("proxy-cache store intent already consumed")

Functions

func ValidateCacheZoneStrategy

func ValidateCacheZoneStrategy(zones []appconfig.Zone, name, strategy string) error

ValidateCacheZoneStrategy validates against an immutable generation-local zone snapshot.

Types

type Config

type Config struct {
	CacheZone         string   `json:"cache_zone,omitempty"`
	CacheStrategy     string   `json:"cache_strategy,omitempty"`
	CacheKey          []string `json:"cache_key,omitempty"`
	CacheBypass       []string `json:"cache_bypass,omitempty"`
	CacheMethod       []string `json:"cache_method,omitempty"`
	CacheHTTPStatus   []int    `json:"cache_http_status,omitempty"`
	HideCacheHeaders  bool     `json:"hide_cache_headers,omitempty"`
	CacheControl      bool     `json:"cache_control,omitempty"`
	NoCache           []string `json:"no_cache,omitempty"`
	CacheTTL          int      `json:"cache_ttl,omitempty"`
	ConsumerIsolation bool     `json:"consumer_isolation,omitempty"`
	CacheSetCookie    bool     `json:"cache_set_cookie,omitempty"`
	// contains filtered or unexported fields
}

func (*Config) UnmarshalJSON

func (c *Config) UnmarshalJSON(data []byte) error

type DiskZoneStore

type DiskZoneStore struct {
	// contains filtered or unexported fields
}

DiskZoneStore exposes the common versioned disk envelope to plugins that share a configured proxy-cache zone. It deliberately leaves cache-key and vary-index policy to the owning plugin.

func NewDiskZoneStore

func NewDiskZoneStore(zones []appconfig.Zone, name string) (*DiskZoneStore, bool, error)

NewDiskZoneStore resolves and prepares a disk store from an immutable generation-local zone snapshot.

func (*DiskZoneStore) Cleanup

func (s *DiskZoneStore) Cleanup(now time.Time)

func (*DiskZoneStore) Delete

func (s *DiskZoneStore) Delete(storageKey string) bool

func (*DiskZoneStore) Load

func (s *DiskZoneStore) Load(storageKey string, now time.Time) (SharedCacheEntry, bool, bool)

Load returns expired=true when an existing entry was removed because its TTL elapsed. This lets the caller preserve APISIX's visible EXPIRED status.

func (*DiskZoneStore) Store

func (s *DiskZoneStore) Store(storageKey string, entry SharedCacheEntry) error

type MemoryZoneStore

type MemoryZoneStore struct {
	// contains filtered or unexported fields
}

MemoryZoneStore provides a reference-counted view of a configured memory zone. It is used by proxy-cache and graphql-proxy-cache to share the same entries without exposing the plugin's internal vary index.

func AcquireMemoryZoneStore

func AcquireMemoryZoneStore(zones []appconfig.Zone, name string) *MemoryZoneStore

AcquireMemoryZoneStore acquires a store from an immutable generation-local zone snapshot.

func (*MemoryZoneStore) Close

func (s *MemoryZoneStore) Close()

func (*MemoryZoneStore) Delete

func (s *MemoryZoneStore) Delete(key string) bool

func (*MemoryZoneStore) DeleteVariants

func (s *MemoryZoneStore) DeleteVariants(key string) bool

DeleteVariants removes all request variants for one base cache key.

func (*MemoryZoneStore) Load

func (s *MemoryZoneStore) Load(key string) (SharedCacheEntry, bool)

func (*MemoryZoneStore) Store

func (s *MemoryZoneStore) Store(key string, entry SharedCacheEntry)

func (*MemoryZoneStore) StoreVariant

func (s *MemoryZoneStore) StoreVariant(key string, requestHeader http.Header, shared SharedCacheEntry)

StoreVariant atomically admits both the entry and its Vary metadata to the configured zone. Oversized entries leave the existing variants untouched.

func (*MemoryZoneStore) VariantKey

func (s *MemoryZoneStore) VariantKey(key string, requestHeader http.Header) string

VariantKey resolves a request against the zone-owned Vary index. The index is evicted and budgeted together with the entries it references.

type Plugin

type Plugin struct {
	base.BasePlugin
	// contains filtered or unexported fields
}

func (*Plugin) Config

func (p *Plugin) Config() any

func (*Plugin) Handler

func (p *Plugin) Handler(next http.Handler) http.Handler

func (*Plugin) Init

func (p *Plugin) Init() error

func (*Plugin) PostInit

func (p *Plugin) PostInit() error

func (*Plugin) RunFinalResponseStore

func (p *Plugin) RunFinalResponseStore(r *http.Request, state base.ResponseState) error

func (*Plugin) RunHeaderFilter

func (p *Plugin) RunHeaderFilter(r *http.Request, state *base.ResponseState) error

RunHeaderFilter hides client cache headers while retaining their upstream values for the later store's cacheability and TTL decisions.

func (*Plugin) RunRequestPhase

func (p *Plugin) RunRequestPhase(w http.ResponseWriter, r *http.Request) base.RequestPhaseResult

func (*Plugin) SetConfiguredZones

func (p *Plugin) SetConfiguredZones(zones []appconfig.Zone)

SetConfiguredZones supplies the generation-local proxy-cache zone snapshot before PostInit.

func (*Plugin) Stop

func (p *Plugin) Stop()

type SharedCacheEntry

type SharedCacheEntry struct {
	Header    http.Header
	Body      []byte
	Status    int
	StoredAt  time.Time
	TTL       time.Duration
	ExpiresAt time.Time
}

SharedCacheEntry is the cache envelope exchanged by plugins that use the configured proxy-cache zones. The fields intentionally mirror the persisted disk envelope so memory and disk strategies keep the same expiry contract.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL