GzipRedisSerializer
GZIP 압축 Redis 직렬화기. 데이터를 GZIP 압축하여 Redis에 저장.
클래스 정의
class GzipRedisSerializer<T>(
private val serializer: RedisSerializer<T>
) : RedisSerializer<T>메서드
serialize()
override fun serialize(obj: T?): ByteArray객체를 GZIP 압축하여 ByteArray 반환.
deserialize()
override fun deserialize(bytes: ByteArray?): T?GZIP 압축 해제하여 객체 반환.
내부 클래스
GZIPOutputStreamWithLevel
class GZIPOutputStreamWithLevel(bos: ByteArrayOutputStream) : GZIPOutputStream(bos)압축 레벨 설정 가능한 GZIP 출력 스트림.
압축 설정
| 설정 | 값 |
|---|---|
| 압축 레벨 | BEST_SPEED (빠른 압축) |
| 인코딩 | UTF-8 |
특징
- 데코레이터 패턴: 기존 Serializer를 감싸서 압축 기능 추가
- BEST_SPEED: 빠른 압축 우선 (압축률보다 속도)
- UTF-8 인코딩: 문자열 처리 시 UTF-8 사용