package cache

import "github.com/open-policy-agent/opa/topdown/cache"

Package cache defines the inter-query cache interface that can cache data across queries

Deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended. For newer features and behaviours, such as defaulting to the Rego v1 syntax, use the corresponding components in the github.com/open-policy-agent/opa/v1 package instead. See https://www.openpolicyagent.org/docs/latest/v0-compatibility/ for more information.

Index

Types

type Config

type Config = v1.Config

Config represents the configuration for the inter-query builtin cache.

func ParseCachingConfig

func ParseCachingConfig(raw []byte) (*Config, error)

ParseCachingConfig returns the config for the inter-query cache.

type InterQueryBuiltinCacheConfig

type InterQueryBuiltinCacheConfig = v1.InterQueryBuiltinCacheConfig

InterQueryBuiltinCacheConfig represents the configuration of the inter-query cache that built-in functions can utilize. MaxSizeBytes - max capacity of cache in bytes ForcedEvictionThresholdPercentage - capacity usage in percentage after which forced FIFO eviction starts StaleEntryEvictionPeriodSeconds - time period between end of previous and start of new stale entry eviction routine

type InterQueryBuiltinValueCacheConfig

type InterQueryBuiltinValueCacheConfig = v1.InterQueryBuiltinValueCacheConfig

InterQueryBuiltinValueCacheConfig represents the configuration of the inter-query value cache that built-in functions can utilize. MaxNumEntries - max number of cache entries

type InterQueryCache

type InterQueryCache = v1.InterQueryCache

InterQueryCache defines the interface for the inter-query cache.

func NewInterQueryCache

func NewInterQueryCache(config *Config) InterQueryCache

NewInterQueryCache returns a new inter-query cache. The cache uses a FIFO eviction policy when it reaches the forced eviction threshold. Parameters:

config - to configure the InterQueryCache

func NewInterQueryCacheWithContext

func NewInterQueryCacheWithContext(ctx context.Context, config *Config) InterQueryCache

NewInterQueryCacheWithContext returns a new inter-query cache with context. The cache uses a combination of FIFO eviction policy when it reaches the forced eviction threshold and a periodic cleanup routine to remove stale entries that exceed their expiration time, if specified. If configured with a zero stale_entry_eviction_period_seconds value, the stale entry cleanup routine is disabled.

Parameters:

ctx - used to control lifecycle of the stale entry cleanup routine
config - to configure the InterQueryCache

type InterQueryCacheValue

type InterQueryCacheValue = v1.InterQueryCacheValue

InterQueryCacheValue defines the interface for the data that the inter-query cache holds.

type InterQueryValueCache

type InterQueryValueCache = v1.InterQueryValueCache

func NewInterQueryValueCache

func NewInterQueryValueCache(ctx context.Context, config *Config) InterQueryValueCache

Source Files

cache.go doc.go

Version
v1.4.2 (latest)
Published
May 2, 2025
Platform
linux/amd64
Imports
2 packages
Last checked
5 hours ago

Tools for package owners.