AsciidocFX
AsciidocFX copied to clipboard
Fix misunderstanding logging statement in BinaryCacheServiceImpl.java
Pull Request Title:
Improve Logging Statements and Correct Spelling in shrinkCache Method
Description:
This pull request improves the logging statements and corrects a spelling error in the shrinkCache method. The changes enhance the clarity and accuracy of the log messages when shrinking the cache.
Original Code:
private void shrinkCache() {
threadService.runTaskLater(() -> {
Collection<CacheData> values = cache.values();
logger.debug("Shrink cache: {}", values.size());
values.stream().filter(e -> e.inMemory()).sorted((o1, o2) -> {
Long l1 = o1.lastModified();
Long l2 = o2.lastModified();
return l2.compareTo(l1);
}).limit(5).forEach(cacheData -> {
logger.debug("Shrinked: {}", cacheData.key());
byte[] bytes = cacheData.readBytes();
saveInDisk(cacheData.key(), bytes);
totalSize.addAndGet(-bytes.length);
});
});
}
Changes:
-
Logging Detail Enhancement:
- Added more context to the initial shrinking log statement to indicate the total number of cache entries.
- Original:
logger.debug("Shrink cache: {}", values.size()); - Improved:
logger.debug("Shrinking cache, total entries: {}", values.size()); - Reason: Provides more context and clarity about the action being performed.
-
Spelling Correction:
- Original:
logger.debug("Shrinked: {}", cacheData.key()); - Improved:
logger.debug("Shrunk cache entry: {}", cacheData.key()); - Reason: Corrects the grammatical error from "Shrinked" to "Shrunk".
- Original:
Code Changes:
private void shrinkCache() {
threadService.runTaskLater(() -> {
Collection<CacheData> values = cache.values();
logger.debug("Shrinking cache, total entries: {}", values.size());
values.stream().filter(CacheData::inMemory).sorted((o1, o2) -> {
Long l1 = o1.lastModified();
Long l2 = o2.lastModified();
return l2.compareTo(l1);
}).limit(5).forEach(cacheData -> {
logger.debug("Shrunk cache entry: {}", cacheData.key());
byte[] bytes = cacheData.readBytes();
saveInDisk(cacheData.key(), bytes);
totalSize.addAndGet(-bytes.length);
});
});
}