Node SDK "bucket.get(id)" appears to return cached results - how to clear

Configuration and environment details:

Execution context: AWS lambda State Machine(workflow) with several states (mostly lambda functions)
Node Version: 14.x
Couchbase SDK Ver. 2.6.9
Couchbase Server ver. 6.0.x with 2-nodes (dev and test share these equally)

what I suspect may be occurring
Given sequential calls to bucket.get(id) for the same document id the results from the previous call is cached and returned to the subsequent call.

my question
Please provide an example how one would force the SDK to not return the result from the previous, identical request?

If more information is necessary, I offer the details below:

What works as expected and perfectly:

  • Prior to execution of the lambda function invoking the workflow above we are interacting and updating the CB cluster a few times before the function invokes the above detailed workflow.
  • Then, the workflow is invoked from a calling lambda function
  • Within the workflow, data is written to our cluster in several of these states(steps) with no issue.
  • Where needed, I am able to read the updates applied previous writes, including the results of a N1QL MERGE statement.
  • The workflow completes successfully and returns control to the calling lambda.
  • The workflow cannot return anything but confirmation metadata provided by the service

Issue I am experiencing
When the calling lambda receives confirmation the workflow has completed successfully, the function calls:
bucket.get(id)
Although the results are returned, they do not reflect the updates applied as a result of the workflow. I can confirm the results are successfully updated in the cluster by invoking a second http call to our api and/or querying the CB console.

what I have tried
Placing the bucket.get(id) call in a second function within the same JavaScript file - does not resolve
Cloning the original connection to a second bucket and invoking bucket2.get(id) - does not resolve

Is there a way to clear cached results from identical calls from the SDK bucket.get(id)?

Please note:
Although I appreciate the encouragement to do so, we do not have the bandwidth yet to upgrade to any version above 6.0.x. If the code we have written to Node SDK ver. 2.6.x is compatible with later versions with little or no updates, then I would be interested. Also, if we can update out CB server to the latest version without breaking us, that too, I would really like to do.

As always, I appreciate any assistance you may offer.

Jay

Hey @The_Cimmerian ,

bucket.get operations are not cached, and each individual call to the method performs a full network call to receive the data from the server. Additionally, the server will always return the most recent version of the data. The only case I’m aware of where cached results might be returned is with regards to N1QL indexes and covered indexes, where until the index is updated there is a period of time where you could receive stale results (if you don’t specify an explicit consistency requirement).

Cheers, Brett

Thanks @brett19 .

What is interesting is the updates are reflected after the merge statement is applied in, say, State function One with the results returned to the next state. Those are logged in the subsequent state, proving the update succeeded.

However, when execution is completed, the calling lambda function must invoke SDK get because an Express workflow is a one-way flow, meaning, it cannot return the results, only the id and status of the state machine workflow.

Just.so.weird. which is why I speculated the caching. If I make a separate call to the API to get the updated record, the updates are present in the separate call.