-
Notifications
You must be signed in to change notification settings - Fork 59
Caching with Spring Boot & Redis
Furkan Kürşat Danışmaz edited this page Sep 19, 2018
·
4 revisions
Source Folder: Caching with Redis
Tech Stack:
- spring-boot
- spring-mvc
- spring-data-redis
- log4j2 (slf4j impl)
- project lombok
This is a ready-to-use Maven Java project template with the libraries listed above.
- Reading data from cache (once it is read from the original source) until its TTL
Create a Redis Docker Container
> docker pull redis
> docker run --name redis -p 6379:6379 -d redis
Jedis vs Lettuce
- Both are mature redis clients
- Lettuce is the default client that comes with the Spring-Boot-Starter-Data-Redis
- Redis is single threaded in terms of data access
- Jedis is not thread safe when applications want to share a single Jedis instance across multiple threads
- The approach to use Jedis in a multi-threaded environment is to use connection pooling (each thread gets its own Jedis instance)
- Lettuce is built in netty and connection instances can be shared across multiple threads
Redis Cache Manager In spring boot, RedisCacheManager is autoconfigured:
- Spring cache configurations using "spring.cache.*"" property
- redis cache configurations using "spring.cache.redis.*" property
NOTE: All default configurations of Spring-Boot are in the files:
spring-configuration-metadata.json
additional-spring-configuration-metadata.json
- Home
- JPA Specification
- JMS with Spring Boot
- JMS with Spring Boot & Apache Camel
- Caching with Spring Boot & Redis
- Netflix Eureka with Spring Boot
- Netflix Hystrix & Eureka with Redis Cache
- Netflix Zuul
- Authentication Types
- Separating Unit & Integration Tests Execution Phases with Maven
- Basic CSRF Attack Simulation & Protection
- Spring Batch
- Dagger
- Concurrency with Java
- Swagger2 with Spring Boot