cache

package
v1.9.11 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const AppIndex = "app"

AppIndex identify the index for resourcetracker to accelerate cache retrieval

Variables

View Source
var (
	// ApplicationRevisionDefinitionCachePruneDuration the prune duration for application revision definition cache
	ApplicationRevisionDefinitionCachePruneDuration = time.Hour
)
View Source
var DefaultDefinitionCache = singleton.NewSingleton(NewDefinitionCache)

DefaultDefinitionCache the default definition cache

View Source
var (
	// OptimizeListOp optimize ResourceTracker & ApplicationRevision list op by adding index
	// used in controller optimization (informer index). Client side should not use it.
	OptimizeListOp = false
)

Functions

func AddInformerTransformFuncToCacheOption

func AddInformerTransformFuncToCacheOption(opts *cache.Options)

AddInformerTransformFuncToCacheOption add informer transform func to cache option This will filter out the unnecessary fields for cached objects and use definition cache to reduce the duplicated storage of same definitions

func BuildCache

func BuildCache(ctx context.Context, scheme *runtime.Scheme, shardingObjects ...client.Object) cache.NewCacheFunc

BuildCache if optimize-list-op enabled, ResourceTracker and ApplicationRevision will be cached by application namespace & name

func NewResourcesToDisableCache

func NewResourcesToDisableCache() []client.Object

NewResourcesToDisableCache get ClientDisableCacheFor for building controller

Types

type DefinitionCache

type DefinitionCache struct {
	ComponentDefinitionCache    *ObjectCache[v1beta1.ComponentDefinition]
	TraitDefinitionCache        *ObjectCache[v1beta1.TraitDefinition]
	WorkflowStepDefinitionCache *ObjectCache[v1beta1.WorkflowStepDefinition]
}

DefinitionCache cache for definitions

func NewDefinitionCache

func NewDefinitionCache() *DefinitionCache

NewDefinitionCache create DefinitionCache

func (*DefinitionCache) RemapRevision

func (in *DefinitionCache) RemapRevision(rev *v1beta1.ApplicationRevision)

RemapRevision remap all definitions in the given revision

func (*DefinitionCache) Start

func (in *DefinitionCache) Start(ctx context.Context, store cache.Cache, duration time.Duration)

Start clear cache every duration

func (*DefinitionCache) UnmapRevision

func (in *DefinitionCache) UnmapRevision(rev *v1beta1.ApplicationRevision)

UnmapRevision unmap definitions from the provided revision by the given ref

type ObjectCache

type ObjectCache[T any] struct {
	// contains filtered or unexported fields
}

ObjectCache cache for objects

func NewObjectCache

func NewObjectCache[T any]() *ObjectCache[T]

NewObjectCache create an object cache

func (*ObjectCache[T]) Add

func (in *ObjectCache[T]) Add(hash string, obj *T, ref string) *T

Add insert cache entry with ref, return the ptr of the entry

func (*ObjectCache[T]) DeleteRef

func (in *ObjectCache[T]) DeleteRef(hash string, ref string)

DeleteRef delete ref for an obj

func (*ObjectCache[T]) Get

func (in *ObjectCache[T]) Get(hash string) *T

Get retrieve the cache entry

func (*ObjectCache[T]) Prune

func (in *ObjectCache[T]) Prune(outdated time.Duration) int

Prune remove outdated cache, return the pruned count

func (*ObjectCache[T]) Remap

func (in *ObjectCache[T]) Remap(m map[string]*T, ref string)

Remap relocate the object ptr with given ref

func (*ObjectCache[T]) Size

func (in *ObjectCache[T]) Size() int

Size get the size of the cache

func (*ObjectCache[T]) Unmap

func (in *ObjectCache[T]) Unmap(m map[string]*T, ref string)

Unmap drop all the hash object from the map

type ObjectCacheEntry

type ObjectCacheEntry[T any] struct {
	// contains filtered or unexported fields
}

ObjectCacheEntry entry for object cache

Jump to

Keyboard shortcuts

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