Skip to content

Commit 46155ec

Browse files
simonbairdclaude
andcommitted
Adjust cache var names for clarity
Since we're using the cache for both image files and blob files, let's stop calling it imageFilesCache. Same thing for single flight. Suggested by Qodo in code review. Co-authored-by: Claude Code <[email protected]> Ref: https://issues.redhat.com/browse/EC-1681
1 parent f54b1df commit 46155ec

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

internal/rego/oci/oci.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -742,10 +742,10 @@ func ClearCaches() {
742742
// Lighter caches (manifests, descriptors, image indexes) remain global because they
743743
// are small and benefit from cross-component sharing (e.g., shared task bundle manifests).
744744
type ComponentCache struct {
745-
blobCache sync.Map
746-
blobFlight singleflight.Group
747-
imageFilesCache sync.Map
748-
imageFilesFlight singleflight.Group
745+
blobCache sync.Map
746+
blobFlight singleflight.Group
747+
filesCache sync.Map
748+
filesFlight singleflight.Group
749749
}
750750

751751
type componentCacheKey struct{}
@@ -927,15 +927,15 @@ func ociImageFiles(bctx rego.BuiltinContext, refTerm *ast.Term, pathsTerm *ast.T
927927
cc := componentCacheFromContext(bctx.Context)
928928

929929
// Check cache first (fast path)
930-
if cached, found := cc.imageFilesCache.Load(cacheKey); found {
930+
if cached, found := cc.filesCache.Load(cacheKey); found {
931931
logger.Debug("Image files served from cache")
932932
return cached.(*ast.Term), nil
933933
}
934934

935935
// Use singleflight to prevent thundering herd
936-
result, err, _ := cc.imageFilesFlight.Do(cacheKey, func() (any, error) {
936+
result, err, _ := cc.filesFlight.Do(cacheKey, func() (any, error) {
937937
// Double-check cache inside singleflight
938-
if cached, found := cc.imageFilesCache.Load(cacheKey); found {
938+
if cached, found := cc.filesCache.Load(cacheKey); found {
939939
logger.Debug("Image files served from cache (after singleflight)")
940940
return cached, nil
941941
}
@@ -996,7 +996,7 @@ func ociImageFiles(bctx rego.BuiltinContext, refTerm *ast.Term, pathsTerm *ast.T
996996

997997
logger.Debug("Successfully extracted image files")
998998
term := ast.NewTerm(filesValue)
999-
cc.imageFilesCache.Store(cacheKey, term)
999+
cc.filesCache.Store(cacheKey, term)
10001000
return term, nil
10011001
})
10021002

@@ -1031,15 +1031,15 @@ func ociBlobFiles(bctx rego.BuiltinContext, refTerm *ast.Term, pathsTerm *ast.Te
10311031
cc := componentCacheFromContext(bctx.Context)
10321032

10331033
// Check cache first (fast path)
1034-
if cached, found := cc.imageFilesCache.Load(cacheKey); found {
1034+
if cached, found := cc.filesCache.Load(cacheKey); found {
10351035
logger.Debug("Blob files served from cache")
10361036
return cached.(*ast.Term), nil
10371037
}
10381038

10391039
// Use singleflight to prevent thundering herd
1040-
result, err, _ := cc.imageFilesFlight.Do(cacheKey, func() (any, error) {
1040+
result, err, _ := cc.filesFlight.Do(cacheKey, func() (any, error) {
10411041
// Double-check cache inside singleflight
1042-
if cached, found := cc.imageFilesCache.Load(cacheKey); found {
1042+
if cached, found := cc.filesCache.Load(cacheKey); found {
10431043
logger.Debug("Blob files served from cache (after singleflight)")
10441044
return cached, nil
10451045
}
@@ -1091,7 +1091,7 @@ func ociBlobFiles(bctx rego.BuiltinContext, refTerm *ast.Term, pathsTerm *ast.Te
10911091
if len(targetPaths) == 0 {
10921092
logger.Debug("No paths specified, returning empty result")
10931093
term := ast.NewTerm(ast.NewObject())
1094-
cc.imageFilesCache.Store(cacheKey, term)
1094+
cc.filesCache.Store(cacheKey, term)
10951095
return term, nil
10961096
}
10971097

@@ -1203,7 +1203,7 @@ func ociBlobFiles(bctx rego.BuiltinContext, refTerm *ast.Term, pathsTerm *ast.Te
12031203

12041204
logger.WithField("file_count", len(extractedFiles)).Debug("Successfully extracted blob files")
12051205
term := ast.NewTerm(filesValue)
1206-
cc.imageFilesCache.Store(cacheKey, term)
1206+
cc.filesCache.Store(cacheKey, term)
12071207
return term, nil
12081208
})
12091209

0 commit comments

Comments
 (0)