콘텐츠로 이동
Bluetape4k 문서1.11

Cache provider와 Spring Data Redis 분리

최신 안정판 Bluetape4k 1.11.0 릴리스 기준

Redis client가 곧 cache provider는 아니다

섹션 제목: “Redis client가 곧 cache provider는 아니다”

bluetape4k-lettucebluetape4k-redisson은 Redis client와 client-specific helper를 제공합니다. bluetape4k-redis는 이 두 모듈을 함께 내보낼 뿐입니다. 함수 결과 memoization, cache-aside loader/writer, Spring Cache manager나 Hibernate 2차 cache는 별도 문제입니다.

필요한 기능선택할 모듈우산 모듈과의 관계
Lettuce command와 coroutinebluetape4k-lettuce우산이 함께 내보냄
Redisson 분산 객체와 Near Cachebluetape4k-redisson우산이 함께 내보냄
cache abstraction과 Lettuce backendbluetape4k-cache-lettuce별도 artifact
cache abstraction과 Redisson backendbluetape4k-cache-redisson별도 artifact
Hibernate 2차 cachebluetape4k-hibernate-cache-lettuce별도 provider·region lifecycle
Spring Data Redis serializerbluetape4k-spring-boot-redis별도 Spring Boot module

애플리케이션이 key-value command를 직접 실행한다면 client module에서 시작합니다. 동일 함수의 결과를 TTL로 재사용하거나 loader/writer와 cache-aside 정책을 공통화하려면 cache module을 선택합니다. Redisson RMapCache를 쓴다고 DB read-through가 자동으로 생기는 것도 아닙니다. 실제 MapLoaderMapWriter 연결 여부를 확인합니다.

Cache Core 매뉴얼은 cache-aside, stampede, Near Cache와 실패 계약을 provider와 분리해 설명합니다. provider 선택 전에 이 추상화가 필요한지 먼저 확인합니다.

Spring Data Redis는 별도 진입점이다

섹션 제목: “Spring Data Redis는 별도 진입점이다”

bluetape4k-spring-boot-redisRedisTemplateReactiveRedisTemplate에 쓸 serializer와 serialization context를 제공합니다. 이 모듈의 dependency와 auto-configuration lifecycle은 bluetape4k-redis의 두-client 묶음과 별개입니다.

Spring Data Redis가 Lettuce를 내부 driver로 사용하더라도 애플리케이션이 bluetape4k-lettuce helper를 직접 사용한다는 뜻은 아닙니다. 반대로 Redisson client를 쓰면서 Spring Data serializer module을 함께 사용할 수도 있지만 두 client pool과 serialization 경계를 따로 관리해야 합니다.

Spring Data serializer만 필요하다면 우산 좌표를 추가하지 않습니다.

dependencies {
implementation(platform("io.github.bluetape4k:bluetape4k-dependencies:<version>"))
implementation("io.github.bluetape4k:bluetape4k-spring-boot-redis")
}

Lettuce 기반 cache abstraction이 필요하면 bluetape4k-cache-lettuce를 선택합니다. 그 모듈이 필요한 Lettuce dependency를 이미 선언하므로 우산 좌표를 중복해서 추가할 이유가 없습니다.