Return to site

SpringBoot caching with Redis

· java

Why?

Each of us met the situation when application was working slowly. Even the best code will fall on knees at high load. Caching can be fast and relatively cheap way to increase performance and reduce response time.

What you gonna need?

Maven dependency:
spring-boot-started-data-redis

Annotations:
@Cacheable — Fulfill cache after method execution, next invocation with the same arguments will be omitted and result will be loaded from cache.

@CachePut — Annotation allows to update entry in cache

@CacheEvict — Remove entry from cache

Constraints

Maximum memory — By default redis have no memory limits on 64-bit systems and 3 GB on 32-bit systems.