cache

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheParam = "cache"
)

Variables

This section is empty.

Functions

func Get

func Get(ctx context.Context) *resolverCache

Get extracts the ResolverCache from the context. If the cache is not available in the context (e.g., in tests), it falls back to the shared cache with a logger from the context.

func GetFromCacheOrResolve

func GetFromCacheOrResolve(
	ctx context.Context,
	params []v1.Param,
	resolverType string,
	resolve resolveFn,
) (resolutionframework.ResolvedResource, error)

func ShouldUse

func ShouldUse(
	ctx context.Context,
	resolver ImmutabilityChecker,
	params []v1.Param,
	resolverType string,
) bool

ShouldUse determines whether caching should be used based on: 1. Task/Pipeline cache parameter (highest priority) 2. ConfigMap default-cache-mode (middle priority) 3. System default for resolver type (lowest priority)

func Validate

func Validate(cacheMode string) error

Validate returns an error if the cache mode is not "always", "never", "auto", or empty string (which defaults to auto).

Types

type CacheConfigStore

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

func NewCacheConfigStore

func NewCacheConfigStore(cacheConfigName string, logger configmap.Logger) *CacheConfigStore

func (*CacheConfigStore) GetResolverConfig

func (store *CacheConfigStore) GetResolverConfig() *Config

func (*CacheConfigStore) ToContext

func (store *CacheConfigStore) ToContext(ctx context.Context) context.Context

ToContext returns a new context with the cache's configuration data stored in it.

func (*CacheConfigStore) WatchConfigs

func (store *CacheConfigStore) WatchConfigs(w configmap.Watcher)

type Clock

type Clock interface {
	Now() time.Time
}

Clock is an interface for getting the current time. This allows for testing without relying on actual time for timestamp generation. Note: The underlying k8s LRUExpireCache uses real time for TTL expiration checks, so we cannot use a fake clock to control cache expiration in tests.

type Config

type Config struct {
	MaxSize int
	TTL     time.Duration
}

Config holds the configuration for the resolver cache

func NewConfigFromConfigMap

func NewConfigFromConfigMap(cm *corev1.ConfigMap) (*Config, error)

NewConfigFromConfigMap creates a Config from a ConfigMap

type ImmutabilityChecker

type ImmutabilityChecker interface {
	IsImmutable(params []v1.Param) bool
}

ImmutabilityChecker extends the base Resolver interface with cache-specific methods. Each resolver implements IsImmutable to define what "auto" mode means in their context.

Jump to

Keyboard shortcuts

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