junaiddshaukat commented on code in PR #37214:
URL: https://github.com/apache/beam/pull/37214#discussion_r2662515202


##########
sdks/typescript/src/apache_beam/worker/state.ts:
##########
@@ -62,20 +90,26 @@ export class CachingStateProvider implements StateProvider {
       "base64",
     );
     if (this.cache.has(cacheKey)) {
+      // Cache hit: move to end (most recently used)
+      this.touchCacheEntry(cacheKey);
       return this.cache.get(cacheKey)!;
     }
+    // Cache miss: fetch from underlying provider
     let result = this.underlying.getState(stateKey, decode);
     const this_ = this;
     if (result.type === "promise") {
       result = {
         type: "promise",
         promise: result.promise.then((value) => {
+          // When promise resolves, update cache with resolved value
+          this_.evictIfNeeded();
           this_.cache.set(cacheKey, { type: "value", value });
           return value;
         }),
       };

Review Comment:
   These issues are now fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to