How to cache REST responses, Spring For Android

守給你的承諾、 提交于 2020-01-12 08:12:14

问题


The goal is to cache some responses from web service.

I am using Spring for Android framework - http://www.springsource.org/spring-android#documentation to communicate with restful service. As I know I can add caching into application using some module from the common Spring Framework ( http://viralpatel.net/blogs/cache-support-spring-3-1-m1/ ). Am I right that it is not possible to do using just spring-for-android? What is the solution then?

*I don't have any experience in a common Spring.


回答1:


I am a contributor to RoboSpice. This library offers a nice asynchronous model for network request with caching. We also have a Spring Android Module that you could be interested in.




回答2:


So, it was easier to use extra database for caching purposes. I have used these columns: expiration date, request url, request object (hash), response object (serialized).

I have "asked" for cache just before request was sent to server. It was enough to fulfill my goals, if you need extra features probably you need additional columns.



来源:https://stackoverflow.com/questions/12109202/how-to-cache-rest-responses-spring-for-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!