Documentation
¶
Index ¶
- Variables
- func CacheZoneDeclared(name string) bool
- func RefreshConfiguredZones(zones []appconfig.Zone) error
- func ValidateCacheZone(name string) error
- func ValidateCacheZoneStrategy(name, strategy string) error
- func ValidateConfiguredZones() error
- type Config
- type DiskZoneStore
- type MemoryZoneStore
- type Plugin
- func (p *Plugin) Config() any
- func (p *Plugin) Handler(next http.Handler) http.Handler
- func (p *Plugin) Init() error
- func (p *Plugin) PostInit() error
- func (p *Plugin) RunFinalResponseStore(r *http.Request, state base.ResponseState) error
- func (p *Plugin) RunRequestPhase(w http.ResponseWriter, r *http.Request) base.RequestPhaseResult
- func (p *Plugin) Stop()
- type SharedCacheEntry
Constants ¶
This section is empty.
Variables ¶
var ErrStoreIntentAlreadyConsumed = errors.New("proxy-cache store intent already consumed")
Functions ¶
func CacheZoneDeclared ¶
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 ¶
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 ¶
ValidateCacheZone validates a plugin cache_zone against the configured registry when one is present.
func ValidateCacheZoneStrategy ¶
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 ¶
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) RunFinalResponseStore ¶
func (*Plugin) RunRequestPhase ¶
func (p *Plugin) RunRequestPhase(w http.ResponseWriter, r *http.Request) base.RequestPhaseResult
type SharedCacheEntry ¶
type SharedCacheEntry struct {
}
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.