java - How to optimize REsT webservice calls invocation to reduce the time required to pool contents? -
i working on project rest webservice calls required frequently. using apache outh2 make
- client request: oauthbearerclientrequest
- authorize it: oauthbearerclientrequest( url).setaccesstoken
- get response: oauthresourceresponse.
but mean while each ws call take takes more time respond. wanted know whats ways optimize ws call in case content loading time reduced?
you can consider spring's caching if using spring in application.
a cache hidden , improves application's performance allowing same data read multiple times in fast fashion.
as mentioned in spring documentation:
at core, abstraction applies caching java methods, reducing number of executions based on information available in cache. is, each time targeted method invoked, abstraction apply caching behavior checking whether method has been executed given arguments. if has, then cached result returned without having execute actual method; if has not, method executed, result cached , returned user that, next time method invoked, cached result returned. way, expensive methods (whether cpu or io bound) can executed once given set of parameters , result reused without having execute method again. caching logic applied transparently without interference invoker.
@cacheable("books") public book findbook(isbn isbn) {...}
in snippet above, method findbook associated cache named books. each time method called, cache checked see whether invocation has been executed , not have repeated.
this sample give idea spring caching. example given in official site can refer , gain detailed knowledge here.
some more example can find here also.
Comments
Post a Comment