Skip to content

Commit 9019eb9

Browse files
committed
wip
Signed-off-by: Attila Mészáros <[email protected]>
1 parent 0554195 commit 9019eb9

File tree

1 file changed

+9
-0
lines changed
  • operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/support

1 file changed

+9
-0
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/support/ResourceCache.java

+9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ public ResourceCache(BiPredicate<Pair<P>, P> evictionPredicate) {
1515
this.evictionPredicate = evictionPredicate;
1616
}
1717

18+
public void cacheResource(P afterUpdate) {
19+
var resourceId = ResourceID.fromResource(afterUpdate);
20+
cache.put(resourceId, new Pair<>(null, afterUpdate));
21+
}
22+
1823
public void cacheResource(P beforeUpdate, P afterUpdate) {
1924
var resourceId = ResourceID.fromResource(beforeUpdate);
2025
cache.put(resourceId, new Pair<>(beforeUpdate, afterUpdate));
@@ -26,6 +31,10 @@ public P getFreshResource(P newVersion) {
2631
if (pair == null) {
2732
return newVersion;
2833
}
34+
if (!newVersion.getMetadata().getUid().equals(pair.afterUpdate().getMetadata().getUid())) {
35+
cache.remove(resourceId);
36+
return newVersion;
37+
}
2938
if (evictionPredicate.test(pair, newVersion)) {
3039
cache.remove(resourceId);
3140
return newVersion;

0 commit comments

Comments
 (0)