Cache Json response using Populate and Lookup

I have below simple Json. I am building this Json based on the response which I am getting from target endpoint.

{

SessionId: 1234,

{

Question: Q1,

Answer: Ans1

}

}

I am storing this JSON using populate cache and key fragment I am using as "SessionId". Next time, when the same session ID with a different Question and Answer comes, then it should append the Cached JSON like below

{

SessionId: 1234,

{

Question: Q1,

Answer: Ans1

}

{

Question: Q2,

Answer: Ans2

}

}

is that possible to append the cached JSON as requested?

Solved Solved
0 2 270
1 ACCEPTED SOLUTION

Cache works based on unique identifier key fragments, when you use populate cache it will create a new record with sessionId and will not append.

But you can try using this approach, When you receive response from target endpoint, perform lookup cache to check for sessionId related cache, if it exists, fetch the value and append it using a javascript. Now use complete JSON payload and create a new Populate cache for the sessionId.

View solution in original post

2 REPLIES 2

Cache works based on unique identifier key fragments, when you use populate cache it will create a new record with sessionId and will not append.

But you can try using this approach, When you receive response from target endpoint, perform lookup cache to check for sessionId related cache, if it exists, fetch the value and append it using a javascript. Now use complete JSON payload and create a new Populate cache for the sessionId.

Just FYI, That's not valid JSON. In valid JSON, the left-hand-side for each property is a quoted string, and the right-hand-side is a string or number or boolean, or a compound value (object or array).

Your examples don't follow those rules.