redis cache setup

This commit is contained in:
tenzin metok 2023-04-06 11:30:24 +05:30
parent 625f488a57
commit 6f4c49a95e
3 changed files with 19 additions and 6 deletions

View file

@ -59,6 +59,11 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency>
<!-- adding redis client library -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency> </dependency>
<!-- Databases - Uses H2 by default --> <!-- Databases - Uses H2 by default -->

View file

@ -1,6 +1,6 @@
# database init, supports mysql too # database init, supports mysql too
database=mysql database=mysql
spring.datasource.url=${MYSQL_URL:jdbc:mysql://localhost/petclinic} spring.datasource.url=${MYSQL_URL:jdbc:mysql://localhost:3306/petclinic}
spring.datasource.username=${MYSQL_USER:root} spring.datasource.username=${MYSQL_USER:root}
spring.datasource.password=${MYSQL_PASS:Tech@123} spring.datasource.password=${MYSQL_PASS:Tech@123}
# SQL is written to be idempotent so this is safe # SQL is written to be idempotent so this is safe

View file

@ -1,13 +1,18 @@
# database init, supports mysql too # database init, supports mysql too
database=h2 # database=h2
spring.sql.init.schema-locations=classpath*:db/${database}/schema.sql # spring.sql.init.schema-locations=classpath*:db/${database}/schema.sql
spring.sql.init.data-locations=classpath*:db/${database}/data.sql # spring.sql.init.data-locations=classpath*:db/${database}/data.sql
database=mysql
spring.datasource.url=jdbc:mysql://localhost:3306/petclinic
spring.datasource.username=root
spring.datasource.password=Tech@123
# SQL is written to be idempotent so this is safe
spring.sql.init.mode=always
# Web # Web
spring.thymeleaf.mode=HTML spring.thymeleaf.mode=HTML
# JPA # JPA
spring.jpa.hibernate.ddl-auto=none spring.jpa.hibernate.ddl-auto=update
spring.jpa.open-in-view=true spring.jpa.open-in-view=true
# Internationalization # Internationalization
@ -23,3 +28,6 @@ logging.level.org.springframework=INFO
# Maximum time static resources should be cached # Maximum time static resources should be cached
spring.web.resources.cache.cachecontrol.max-age=12h spring.web.resources.cache.cachecontrol.max-age=12h
# configure the Redis connection settings
spring.redis.host=localhost
spring.redis.port=6379