본문 바로가기
반응형

redis4

Webflux에서 switchIfEmpty가 예상과 다른 동작을... 1. 버그 발견프로젝트의 환경은 아래와 같았습니다.Springboot 3.1.xKotlin라이브러리spring-boot-starter-webfluxspring-boot-starter-data-redis-reactiveetc대략 아래와 같은 느낌(?)의 코드가 있었습니다.//.. 생략return redisTemplate.opsForValue().get(key) .switchIfEmpty { service.doSomething() .map { ResponseEntity.ok(it) // return http ok response } } .flatMap { // return http error respo.. 2025. 6. 12.
Testcontainers로 테스트 코드 만들기 2(with Kotlin) 앞서 Java로 작성했던 Testcontainers로 테스트 코드 만들기를 Kotlin으로도 작성해봅시다. 이번에는 Mysql이 아닌 Redis를 사용한다고 가정합니다. 또한 Webflux 기반 테스트 환경 구축방법에 대해 포스팅합니다. 로컬환경은 아래와 같습니다. Windows 10 JDK 17 Kotlin 1.8 Springboot 3.1.4 Testcontainers 1.17.7 1. 의존성 추가 아래와 같이 build.gradle.kts에 의존성을 추가해줍니다. /* build.gradle.kts */ dependencies { ...(중략) testImplementation("io.mockk:mockk:1.10.4") testImplementation("org.junit.jupiter:junit.. 2024. 1. 18.
Redis를 Docker Compose 로 띄우기 해당 글에서는 NoSQL에 속하며, 인기있는 오픈소스 인메모리 DB인 Redis를 docker로 띄우는 방법을 정리합니다. 01. docker image 다운로드 >> docker pull redis:alpine 위와 같이 pull 커맨드를 이용해서 redis:alpine 이미지를 다운로드 받습니다. alpine 은 태그를 의미하며 redis의 버전 등의 값을 줄수 있습니다. (생략하면 latest 를 받음) alpine 태그의 특징은 이미지를 경량화 시켜서 용량이 적습니다. 이미지 용량 차이를 확인해보니 아래와 같네요. >> docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis alpine c678242f9116 5 weeks ago 31.6MB redi.. 2021. 1. 22.
[Kotlin] Springboot + Redis 사용법 Redis는 메모리 DB로 일반적인 DB(disk를 사용)보다 속도가 빠릅니다. 그렇기 때문에 대량의 데이터를 다루는 서비스에서 캐시 서버로서 많이 사용됩니다. 해당 글에서는 코틀린을 사용해 Springboot + Redis 연동 및 간단한 사용방법을 정리합니다. 01. Dependency 추가 build.gradle.kt 파일을 열어 아래와 같이 Redis 사용을 위한 lib를 추가해줍시다. ...(중략) repositories { mavenCentral() } dependencies { implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-s.. 2020. 4. 26.
반응형