I want to use spring boot with caching data retrieved from rest web service. I propose to use redis for caching data. Is it possible to use embeded redis with spring boot without installing a redis software? If yes with which version of spring boot and how to do it?
Thanks for your responses.
-
1There's no such thing? All the embedded redis frameworks are for integration test. Use an in-memory solution for caching there are some more verbose like Ehcache that could be used if you want more caching control like TTL.Darren Forsythe– Darren Forsythe2018年02月20日 21:47:08 +00:00Commented Feb 20, 2018 at 21:47
-
Thanks Darren! So with Ehcache, it is possible to use cache without installing any software. and i want to know if ehcache offer the possibilty to enable and disable cache?NAZEHA– NAZEHA2018年02月21日 05:48:15 +00:00Commented Feb 21, 2018 at 5:48
2 Answers 2
Redis can't meet your request.
You can of course simply use embedded EhCache within your Spring Boot application. If you want to share the cache, it depends on your architecture. You could expose REST endpoints to make you cache available to other applications.
You can refer: https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-cache.
Spring have annotation @EnableCaching to enable or disable cache. Also, there are four annotations like @Cacheable and @CacheEvict to custom the cache logic.
Comments
Hazelcast supports the scenario you are trying to implement. It has a concept of embedded cache that can be shared/synchronized across the service nodes.
For more details see: