Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
#2 ehcache 임시적용
Browse files Browse the repository at this point in the history
  • Loading branch information
jsy3831 committed Sep 18, 2021
1 parent d2fe3b6 commit 0caccc1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-aop'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-cache'
// implementation 'org.springframework.boot:spring-boot-starter-data-redis'
// implementation 'org.springframework.session:spring-session-data-redis'

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/photobook/PhotobookApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;

@SpringBootApplication
@EnableCaching
public class PhotobookApplication {

public static void main(String[] args) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/photobook/service/impl/UserServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.photobook.mapper.UserMapper;
import com.photobook.dto.UserDto;
import com.photobook.service.UserService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.InternalAuthenticationServiceException;
import org.springframework.security.crypto.password.PasswordEncoder;
Expand Down Expand Up @@ -39,6 +40,7 @@ public UserDto validateLogin(String id, String password) {
}

@Override
@Cacheable(value="findUserCache", key="#id")
public UserDto getUserInfoById(String id) {
UserDto userInfo = userMapper.getUserInfoById(id);
return userInfo;
Expand Down
18 changes: 18 additions & 0 deletions src/main/resources/ehcache.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
updateCheck="false">
<diskStore path="java.io.tmpdir" />

<cache name="findUserCache"
maxEntriesLocalHeap="10000"
maxEntriesLocalDisk="1000"
eternal="false"
diskSpoolBufferSizeMB="20"
timeToIdleSeconds="300" timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
<persistence strategy="localTempSwap" />
</cache>

</ehcache>

0 comments on commit 0caccc1

Please sign in to comment.