How to store multiple cache entries from JSON Response using a value of the record as key

Not applicable

I have a Json response from one of the proxy and I need to store the records of the JSON as Cache for use the next time the proxy is called.

Each record has to be stored separately with email address as cache key.

My Json looks like

  [
    {
        "OfficeID": "1244",
        "AuditorID": "343",
        "FirstName": "P",
        "LastName": "test",
        "EmailAddress": "p@tst.com",
        "PhoneNumber": "666-666-6666",
        "PhoneExtension": " "
    },
    {
        "OfficeID": "2344",
        "AuditorID": "3435",
        "FirstName": "wsr",
        "LastName": "eaf",
        "EmailAddress": "wer@tst.com",
        "PhoneNumber": "444-888-9999",
        "PhoneExtension": " " 
    } 
  ]
Solved Solved
1 3 1,370
2 ACCEPTED SOLUTIONS

One way to do this would be to use Node.js with the apigee-access module to populate the cache. Since the node.js code would need to be in the ScriptedTarget resource, your current target endpoint would need to change to use the node.js app, and you would need to access the real backend via a ServiceCallout policy in the request flow.

The node.js app would need to parse the JSON response from the SC policy , then iterate thru the objects and populate each json object using the emailAddress as cache key.

More details on using apigee-access with cache can be found here: http://docs.apigee.com/api-services/content/access-cache-nodejs

View solution in original post

Not applicable
3 REPLIES 3

One way to do this would be to use Node.js with the apigee-access module to populate the cache. Since the node.js code would need to be in the ScriptedTarget resource, your current target endpoint would need to change to use the node.js app, and you would need to access the real backend via a ServiceCallout policy in the request flow.

The node.js app would need to parse the JSON response from the SC policy , then iterate thru the objects and populate each json object using the emailAddress as cache key.

More details on using apigee-access with cache can be found here: http://docs.apigee.com/api-services/content/access-cache-nodejs

Thank you Miranda, is there a way we can do it without node js? for example using javascript/Java.

Not applicable

Looks like this has been already asked at

https://community.apigee.com/questions/32614/cache-json-array-with-keys.html

thank you!