-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* build: 의존성 추가 * feat: 캐시 설정 추가 * feat: 견종 목록 읽기시 캐싱 적용 * feat: 견종 등록 API 추가 및 등록시 캐싱 해제되도록 설정
- Loading branch information
Showing
9 changed files
with
97 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
backend/src/main/java/zipgo/admin/dto/BreedCreateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package zipgo.admin.dto; | ||
|
||
public record BreedCreateRequest( | ||
Long petSizeId, | ||
String breedName | ||
) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package zipgo.common.cache; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum CacheType { | ||
|
||
BREEDS("breeds", 1), | ||
; | ||
|
||
private final String name; | ||
private final int maxSize; | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
backend/src/main/java/zipgo/common/config/CacheConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package zipgo.common.config; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import com.github.benmanes.caffeine.cache.Cache; | ||
import com.github.benmanes.caffeine.cache.Caffeine; | ||
import org.springframework.cache.CacheManager; | ||
import org.springframework.cache.annotation.EnableCaching; | ||
import org.springframework.cache.caffeine.CaffeineCache; | ||
import org.springframework.cache.support.SimpleCacheManager; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import zipgo.common.cache.CacheType; | ||
|
||
@EnableCaching | ||
@Configuration | ||
public class CacheConfig { | ||
|
||
@Bean | ||
public CacheManager cacheManager() { | ||
SimpleCacheManager cacheManager = new SimpleCacheManager(); | ||
cacheManager.setCaches(caches()); | ||
return cacheManager; | ||
} | ||
|
||
private List<CaffeineCache> caches() { | ||
return Arrays.stream(CacheType.values()) | ||
.map(cacheType -> new CaffeineCache(cacheType.getName(), cache(cacheType))) | ||
.toList(); | ||
} | ||
|
||
private Cache<Object, Object> cache(CacheType cacheType) { | ||
return Caffeine.newBuilder() | ||
.maximumSize(cacheType.getMaxSize()) | ||
.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters