Documentation
¶
Overview ¶
Package cache provides the generic, reusable half of the external cache layer: ObjectCache, a namespace- and generation-scoped field cache for a single CR kind, plus NewExternal, the single composition point that picks and constructs the concrete backend (Redis, Memcached, or a no-op) from Options.
ObjectCache is deliberately generic — it knows nothing about any specific CR's spec shape. The per-kind subpackages (cache/build, cache/deployment, cache/domain, and siblings) embed it and add typed Set* / Get* helpers plus a PublishResolved method that projects a resolved contract into individual fields.
Every read is a fast-path optimization, never a correctness dependency: a miss or backend error always falls through to the informer cache (see core/cache), so this package's failure modes cost queryability, not correctness.
Index ¶
- func NewExternal(opts Options) (corecache.ExternalCache, error)
- type Backend
- type ObjectCache
- func (o *ObjectCache) GetField(ctx context.Context, nn types.NamespacedName, gen int64, field string, ...) (bool, error)
- func (o *ObjectCache) Invalidate(ctx context.Context, nn types.NamespacedName) error
- func (o *ObjectCache) SetField(ctx context.Context, nn types.NamespacedName, gen int64, field string, val any) error
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewExternal ¶
func NewExternal(opts Options) (corecache.ExternalCache, error)
NewExternal is the single composition point for the external cache. Called once from main; everything downstream sees only corecache.ExternalCache.
Types ¶
type Backend ¶
type Backend string
Backend selects which external cache implementation NewExternal constructs.
type ObjectCache ¶
type ObjectCache struct {
// contains filtered or unexported fields
}
ObjectCache provides namespace-aware, generation-scoped field caching for a single CR kind. Domain caches embed this and add typed helpers.
Keys: <kind>:<namespace>/<name>:gen<generation>:<field> Generation scoping means a spec change naturally orphans stale entries (they expire via TTL) — no invalidation hook required, and it works identically on backends without key enumeration (Memcached).
func NewObjectCache ¶
NewObjectCache constructs an ObjectCache scoped to the given CR kind, with fields expiring after ttl (0 disables expiry).
func (*ObjectCache) GetField ¶
func (o *ObjectCache) GetField(ctx context.Context, nn types.NamespacedName, gen int64, field string, into any) (bool, error)
GetField retrieves a value for the given generation. (false, nil) is a miss — fall through to the informer cache.
func (*ObjectCache) Invalidate ¶
func (o *ObjectCache) Invalidate(ctx context.Context, nn types.NamespacedName) error
Invalidate drops all cached fields for an object (all generations). Call on delete events. Backends without enumeration no-op; generation scoping already protects correctness there.
type Options ¶
type Options struct {
Backend Backend
Redis adapter.RedisConfig
Memcached adapter.MemcachedConfig
}
Options configures NewExternal's choice of external cache backend and its connection settings.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package adapter provides concrete core/cache.ExternalCache implementations for the external cache's supported backends: Redis (RedisCache) and Memcached (MemcachedCache).
|
Package adapter provides concrete core/cache.ExternalCache implementations for the external cache's supported backends: Redis (RedisCache) and Memcached (MemcachedCache). |
|
Package build provides domain-specific, field-level caching for Build resources.
|
Package build provides domain-specific, field-level caching for Build resources. |
|
Package deployment provides domain-specific, field-level caching for Deployment resources.
|
Package deployment provides domain-specific, field-level caching for Deployment resources. |
|
Package domain provides domain-specific, field-level caching for Domain resources.
|
Package domain provides domain-specific, field-level caching for Domain resources. |
|
Package environment provides domain-specific, field-level caching for Environment resources.
|
Package environment provides domain-specific, field-level caching for Environment resources. |
|
Package githubevent provides domain-specific, field-level caching for GitHubEvent resources.
|
Package githubevent provides domain-specific, field-level caching for GitHubEvent resources. |
|
Package gitrepository provides domain-specific, field-level caching for GitRepository resources.
|
Package gitrepository provides domain-specific, field-level caching for GitRepository resources. |
|
internal
|
|
|
testutil
Package testutil provides a shared in-memory core/cache.ExternalCache fake for cache/* package tests.
|
Package testutil provides a shared in-memory core/cache.ExternalCache fake for cache/* package tests. |
|
Package packages provides domain-specific, field-level caching for Package resources.
|
Package packages provides domain-specific, field-level caching for Package resources. |
|
Package route provides domain-specific, field-level caching for Route resources.
|
Package route provides domain-specific, field-level caching for Route resources. |
|
Package serviceunit provides domain-specific, field-level caching for ServiceUnit resources.
|
Package serviceunit provides domain-specific, field-level caching for ServiceUnit resources. |