-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- ์ดํ๋ฆฌ์ผ์ด์ ์ข ๋ฃ ์์ ์ ์บ์ ์คํฏ ๋ก๊น
- Loading branch information
1 parent
115c9eb
commit 218aad3
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
backend/src/main/java/com/festago/common/cache/CacheStatsLogger.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,28 @@ | ||
package com.festago.common.cache; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.cache.Cache; | ||
import org.springframework.cache.CacheManager; | ||
import org.springframework.cache.caffeine.CaffeineCache; | ||
import org.springframework.context.event.ContextClosedEvent; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class CacheStatsLogger { | ||
|
||
private final CacheManager cacheManager; | ||
|
||
@EventListener(ContextClosedEvent.class) | ||
public void logCacheStats() { | ||
for (String cacheName : cacheManager.getCacheNames()) { | ||
Cache cache = cacheManager.getCache(cacheName); | ||
if (cache instanceof CaffeineCache caffeineCache) { | ||
log.info("CacheName={} CacheStats={}", cacheName, caffeineCache.getNativeCache().stats()); | ||
} | ||
} | ||
} | ||
} |