일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- MSSQL
- 문서
- SpringBoot
- jpa
- Spring Boot
- oracle
- Python
- PostgreSQL
- Open Source
- Core Java
- git
- MySQL
- 설정
- STS
- Docker
- 오픈소스
- Source
- Exception
- spring
- AJAX
- JavaScript
- ubuntu
- JDBC
- Thymeleaf
- Tomcat
- Eclipse
- myBatis
- error
- maven
- IntelliJ
- Today
- Total
헤르메스 LIFE
[SpringBoot] SpringBoot + Redis Cache Sample 본문
개발환경
Tools : STS 4.22.1.RELEASE
JDK : zulu11.72.19-jdk11.0.23
Framework : Spring Boot 2.7.18
Database : PostgreSQL 16.3
Cache NoSQL : Redis 7.2.5
Build : Gradle
프로젝트 생성

Dependencies 선택

Finish

개발 소스
https://github.com/hermeswing/SpringBootNRedis
GitHub - hermeswing/SpringBootNRedis
Contribute to hermeswing/SpringBootNRedis development by creating an account on GitHub.
github.com
Spring-boot + Redis application.yml 설정 변경
deprecated 되었습니다.
spring:
data:
redis:
host: localhost
port: 6379
아래의 설정으로 변경합니다.
# Spring 설정
spring:
datasource: # Database 설정
# Tibero 설정
# driver-class-name: com.tmax.tibero.jdbc.TbDriver
# url: jdbc:tibero:thin:@121.134.157.73:1521:tibero
# username: CSPIVUE
# password: admin!234
# PostgreSQL 설정
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/springboot
username: hermeswing
password: pass
hikari:
maximum-pool-size: 3 #최대 pool 크기
minimum-idle: 1 #최소 pool 크기
idle-timeout: 600000 #연결위한 최대 유후 시간
max-lifetime: 1800000 #반납된 커넥션의 최대 수명
# Redis 설정
data:
redis:
host: localhost
port: 6379
POST MAN테스트
테스트 목표
1.PostgreSQL Database 에 저장 / 수정 / 삭제 / 조회 가 잘 되어야 합니다.
2. 조회 시 첫번째 조회를 제외하고, 두번째 조회 부터는 Redis 에서 조회 되어야 합니다.
1. 저장 : POST, localhost:9090, Body > raw > JSON
{
"name":"홍길동"
}

저장이 잘 되었습니다.

2. 수정 : PUT, localhost:9090, Body > raw > JSON
{
"id": 1,
"name":"홍길동2"
}

수정도 잘 되네요.

3. 삭제 : DELETE, localhost:9090/1

삭제도 잘 됩니다.

4. 조회 :
- 먼저 "저장" 수행을 진행 합니다.
- localhost:9090/1

정상적으로 조회 됩니다.
Redis 에도 정상적으로 저장 되어 있습니다. ( Redis 에 저장된 데이터는 휘발성 데이터 로 각 데이터 마다 30분 간 저장되게 설정 되어 있습니다.

두번째 조회에서 부터는 Redis에서 조회 되어야 합니다. ( Cache 된 데이터가 조회됩니다. )
그래서 Database 에서 데이터를 수정합니다. ( name 을 "홍길동" 에서 "신사임당" 으로 수정했습니다. )

데이터는 수정되었지만, Redis에 Cache된 데이터를 읽어 오게 되므로 "홍길동"이 조회됩니다.

https://hermeslog.tistory.com/635
[Redis] Docker에 Redis 설치하기
Redis는 In Memory Key, Value 데이터 구조의 데이터를 저장할 수 있는 비정형 데이터 베이스입니다. 메모리 DB 이기때문에 속도가 빠르고, 영속성 및 다양한 데이터 구조와 같은 부가적인 기능을 지원
hermeslog.tistory.com
https://hermeslog.tistory.com/541
[SpringBoot] Docker에 PostgreSQL 설치 / 연결하기
IDE : IntelliJJDK : OpenJDK 11Framework : Spring Boot 2.5.2Database : PostgreSQL 최신버전 ( 라이센스도 소스공개의무도 없음 )첨부파일이 MySqlRunner 로 되어있는데.. MySQL 접속테스트 중 소스만 바뀐거라.. ㅎㅎDocker
hermeslog.tistory.com
https://hermeslog.tistory.com/787
[Exception] Build failed with an exception
개발환경 셋팅 중 아래와 같은 오류가 발생하였습니다.기술의 발전은 빠른데, 따라 가기 힘드네요. ㅠ.ㅠSTS에서 "https://start.spring.io" 를 통해 Springboot 신규 프로젝트를 생성하면 Java version을 17 이
hermeslog.tistory.com
https://hermeslog.tistory.com/568
[Spring Boot] HikariCP를 이용한 Database Connection + JPA
개발환경 1. STS 버전 : 4.13.1 2. JDK 버전 : OpenJDK 11.0.14_9_x64 3. Tomcat 버전 : 9.0.56 4. Maven 버전 : 3.8.4 5. Spring 버전 : Spring Boot 2.6.3 6. Database : Docker 에 DB 설치 - primary - PostgreSQL 13.3 8. lombok PostgreSQL 연결하
hermeslog.tistory.com
[SpringBoot, Redis] Redis를 활용한 Caching 기본 및 활용 예제
한번 읽은(처리된) 데이터를 임시로 저장하고, 필요에 따라 전송, 갱신, 삭제하는 기술이다.보통 서버의 메모리를 사용하는 경우가 많다.메모리를 사용하기 때문에 매번 Disk로부터 데이터를 조
velog.io
'Spring Boot Framework' 카테고리의 다른 글
[Spring Boot] logbak-local 설정 (0) | 2024.08.01 |
---|---|
[Springboot] Springboot 와 Mybatis 설정에서 resultType을 Map 으로 사용 시 문제점. (0) | 2024.07.24 |
[Spring Boot] Mybatis 쿼리 Interceptor 처리 테스트 (0) | 2024.05.23 |
[Spring Cloud Netflix] Eureka Gateway 샘플 (0) | 2024.03.28 |
[Spring Cloud Netflix] Eureka Client 샘플 (0) | 2024.03.14 |