{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Apigee-127 /
avatar image
1
Question by Sathiya Krishnan · Mar 14, 2018 at 02:24 PM · 227 Views api proxy

How to implement cache policy with Java Callout

Hi,

We have implemented java callout which connects to database and forms JSON response.

want to implement cache policy to cache json response from javacallout and send as response in the subsequent request.

We have tried response cache policy but again all the request are hitting bacekend and gives response.

Comment
Add comment
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Close

1 Answer

  • Sort: 
avatar image
0
Best Answer

Answer by Dino   · Mar 14, 2018 at 03:22 PM

I understand that

  • you have a Java callout that connects to a database and forms a JSON blob as an output.
  • you would like to cache this result and use it in later requests
  • You have tried using the ResponseCache policy, but it's not working as desired

You cannot use ResponseCache for this purpose.

I advise that you rely on the LookupCache and PopulateCache policies, as well as the AssignMessage policy. The flow logic will look something like this:

<Step>
  <Name>Cache-LookupJsonBlob</Name>
</Step>
<Step>
  <Condition>cached_result = null</Condition>
  <Name>Java-DatabaseLookup</Name>
</Step>
<Step>
  <Condition>cached_result = null</Condition>
  <Name>Cache-PopulateJsonBlob</Name>
</Step>
<Step>
  <Condition>cached_result = null</Condition>
  <Name>Cache-LookupJsonBlob</Name>
</Step>
<Step>
  <Condition>cached_result = null</Condition>
  <Name>RaiseFault-CacheFailure</Name>
</Step>
<Step>
  <Name>AssignMessage-Response</Name>
</Step>

Does this make sense?

The Cache lookup and Java db read can both be parameterized, of course. The output of the Java callout would be to ... set a context variable.

The Cache-populate step takes THAT context variable and places it into cache with the appropriate key.

The AssignMessage policy takes the output of the Cache lookup policy (a different context variable) and places it into the response message.

Comment
Add comment Show 2 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Sathiya Krishnan · Mar 14, 2018 at 03:32 PM 0
Link

Thanks for the immediate reply.

Do we have to add in preflow or postflow

avatar image Sathiya Krishnan · Mar 14, 2018 at 03:53 PM 0
Link

Could you add polilcy in step wise to understand

Follow this Question

Answers Answers and Comments

61 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Apigee 127 and Apigee BaaS 3 Answers

Need guidance on when we should be using the -u (upload node_modules) option when doing an a127 project deploy 1 Answer

Error generating proxy from WSDL: Unknown Error 0 Answers

Slow response from Edge Proxy -> AWS Lambda 0 Answers

When does it make sense to use the Apigee UI vs creating a proxy via a127? 2 Answers

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges