Okay, so after a few days of going back and forth and retesting the Lookup Cache Policy alot but still getting the same issue. I found out that even though the issue is on the Lookup Cache API, the real issue was caused by the Invalidate Cache Policy. As this never happened to us before when we implemented this with OAuth where there’s also a Lookup and Populate Cache policy but with no Invalidate Cache Policy
At first was, I tested whether if the Invalidate cache really invalidates the proper cache, and its doing so anyway, and it does not invalidate the latest cache that I know should exist. But for some reason, the cache that I know should exist, keeps on saying on every other request that the cache does not exist and then exist again, which add to me suspecting that the Lookup Cache policy not working properly as @ylesyuk is pointing out (I also encountered this sometimes before, but not on a frequent basis such as this one).
However, since I know the Issue only exist whenever I start using my Invalidate Cache Policy. I stopped testing and debugging the the Lookup Cache policy to which I am having issues retrieving the proper cachehit values and instead focused on Invalidated Policy even though it is working properly as it is invalidating the proper Caches.
Turns out, since my Caches share the same static , and I have in my Invalidate Cache, and that my only differs on the 2nd dynamic based on UUID, the Invaldiate Cache it seems to be invalidating the other cache it shouldnt be invalidating on some MPs on what it seems to me. As the cache would still return the proper values on succeeding request. So the fix was that I just removed
<PurgeChildEntries>true</PurgeChildEntries>
in my Invalidate Cache Policy.
My question now really is what is the real use of this parameter and is there further elaboration of its use as the documentation barely explains its full use. I initially thought that this property would just invalidate all caches on all MPs and all keys with the same KeyFragment. But for some reason, it seems to be randomly invalidating caches (otherwise not in the reference value of KeyFragment) on some MPs that has a different KeyFragment like the one below
<KeyFragment>Authorize</KeyFragment><KeyFragment ref="request.queryparam.SessionId">
where SessionId is always changing. Leading me to this issue where the Lookup Cache Policy would sometimes always find the Cache I’m looking for and sometime it wouldn’t and randomly throw either true or false in the cachehit response. But then one of the cause it took me longer to find the issue was that, I expected property to actually delete all records with the same KeyFragment, cuz if it did, it would always return false even though I know the cache should exist, rather, it seems to be not doing so and just invalidates cache on some MPs but still retain some randomly, hence the intermittent values I’m getting in the Lookup Policy.
Is this how it is supposed to work? @Dino-at-Google . Thx.