How to cache REST responses, Spring For Android

2019-03-28 11:56发布

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.

2条回答
Juvenile、少年°
2楼-- · 2019-03-28 12:09

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.

查看更多
Viruses.
3楼-- · 2019-03-28 12:21

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.

查看更多
登录 后发表回答