Spring Data Rest - Caching

≯℡__Kan透↙ 提交于 2019-11-30 13:31:08

问题


How to enable caching with Spring Data Rest?

The reasoning behind is that repository listing and search methods won't change once the application is up. Also if the data behind the rest API is changed only through rest API it does makes a case to enable caching data too.

I believe some level is caching happens in REST API framework and it would be ideal if the caching happens at the final response stage i.e., json response (to avoid the overhead of marshalling objects to json)

Thoughts/comments?


回答1:


The easiest way to implement this on the repository level is to use Spring's @Cacheable as it can be seen in the Spring Data JPA Examples project.

Another option is to leverage HTTP Caching using the Apache HTTPD settings or a Varnish for example.



来源:https://stackoverflow.com/questions/18362173/spring-data-rest-caching

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