proxy_cache

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 19 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 CacheZoneDeclared

func CacheZoneDeclared(name string) bool

CacheZoneDeclared reports whether a zone is present in the configured proxy-cache registry. An empty registry intentionally retains compatibility with local, process-only cache fallbacks.

func RefreshConfiguredZones

func RefreshConfiguredZones(zones []appconfig.Zone) error

RefreshConfiguredZones validates and atomically publishes a complete proxy-cache zone snapshot. An invalid snapshot leaves the last valid configuration untouched; existing plugin instances keep their current memory-zone generation until they stop.

func ValidateCacheZone

func ValidateCacheZone(name string) error

ValidateCacheZone validates a plugin cache_zone against the configured registry when one is present.

func ValidateCacheZoneStrategy

func ValidateCacheZoneStrategy(name, strategy string) error

ValidateCacheZoneStrategy validates a plugin cache_zone against the configured zone's storage strategy. A configured disk_path makes a zone disk-backed; a zone without one is memory-backed.

func ValidateConfiguredZones

func ValidateConfiguredZones() error

ValidateConfiguredZones validates the complete static proxy-cache zone registry before a route replacement starts. An empty registry preserves the compatibility fallback used when no zones are declared.

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(name string) (*DiskZoneStore, bool, error)

NewDiskZoneStore resolves and prepares a configured disk zone. configured is false when the process has no proxy-cache zone registry, preserving the compatibility in-memory fallback used by local tests and development.

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(name string) *MemoryZoneStore

AcquireMemoryZoneStore acquires a reference to a named shared memory zone. Call Close when the owning plugin instance stops.

func (*MemoryZoneStore) Close

func (s *MemoryZoneStore) Close()

func (*MemoryZoneStore) Delete

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

func (*MemoryZoneStore) Load

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

func (*MemoryZoneStore) Store

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

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

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

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