카테고리 없음

[Redis] 레디스 사용하면서 발생한 오류를 모아보자 !

개발에목마른쭌 2023. 7. 12. 16:11
ache 'product' does not allow 'null' values; Avoid storing null via '@Cacheable(unless="#result == null")' or configure RedisCache to allow 'null' via RedisCacheConfiguration
	at org.springframework.data.redis.cache.RedisCache.put(RedisCache.java:144) ~[spring-data-redis-3.1.0.jar:3.1.0]

 RedisConfig 설정시 아래와 같은 설정을 해서 발생한 오류이다.

.disableCachingNullValues()

 

레디스에 null값을 캐싱하게 되면 쓸데없는 메모리를 잡아먹을 수 있기 때문에 null값은 캐싱되지 않도록 설정해줘야 한다.

하지만 위와 같은 설정은 단순히 null이 캐싱되지 않는게 아니라 null값으로 캐싱을 시도하면 예외를 발생시킨다.

그래서 오류 구문을 잘읽어보면 @Cacheable(unless="#result == null"을 통해 막아줘야 한다고 한다.

자세한 내용은 https://findmypiece.tistory.com/105