직렬화
- 객체를 데이터 스트림으로 만드는 것.
- 객체에 저장된 데이터를 스트림에 쓰기 위해 연속적인 데이터로 변환하는 것
- 객체를 다른 곳으로 전송하거나 저장하기 위해서 사용.
- 객체의 필드를 바이너리 형식이나 바이트스트림으로 바꾸는 작업. 직렬화 되는 대상은 객체의 인스턴스 변수
역직렬화
- 직렬화의 반대로 다시 객체의 형태로 만드는 것
Redis의 데이터 저장 형식은 byte array형태이다. 직렬화가 필요하다
Spring Data Redis 직렬기
- JdkSerializationRedisSerializer
- RedisCache와 RedisTemplate에서 default로 사용됨
- StringRedisSerializer
- String형태로 저장
- JacksonJsonRedisSerializer
- Json형태로 저장
- 객체 클래스를 지정해주어야 한다
- GenericJackson2JsonRedisSerializer
- Json형태로 저장
- 객체 클래스를 지정해주지 않아도 된다. 단 직렬화되는 Dto가 같은 패키지 내에 있어야 한다.
source
https://docs.spring.io/spring-data/data-redis/docs/current/reference/html/#redis:serializer
Spring Data Redis
Some commands (such as SINTER and SUNION) can only be processed on the server side when all involved keys map to the same slot. Otherwise, computation has to be done on client side. Therefore, it is useful to pin keyspaces to a single slot, which lets make
docs.spring.io
https://yakolla.tistory.com/46
spring-data redis serializer 사용하기
redis의 데이터 저장 형식은 byte array형태이며, 사용하는 쪽에서 포맷을 정하여 저장하고 불러와야 한다. spring-data redis는 자주 쓸만한 포맷을 편하게 쓸 수 있도록 시리얼라이저 클래스로 내장되
yakolla.tistory.com
'Framework > Spring' 카테고리의 다른 글
[Spring] 컴포넌트 스캔과 의존관계 자동 주입 (0) | 2023.03.16 |
---|---|
[Spring] 싱글톤 컨테이너 (0) | 2023.03.16 |
[Spring] 스프링 컨테이너와 스프링 빈 (0) | 2023.03.16 |
[Spring] DI와 IoC (0) | 2023.03.13 |
[Spring] log4jdbc 이용해서 Mybatis 쿼리 로그 남기기 (0) | 2022.10.20 |