Better logger name

This commit is contained in:
kssenii 2024-04-03 19:06:33 +02:00
parent f0dac3dfd5
commit 2db1e34517
3 changed files with 16 additions and 7 deletions

View File

@ -90,9 +90,15 @@ FileCache::FileCache(const std::string & cache_name, const FileCacheSettings & s
, metadata(settings.base_path, settings.background_download_queue_size_limit, settings.background_download_threads, write_cache_per_user_directory)
{
if (settings.cache_policy == "LRU")
main_priority = std::make_unique<LRUFileCachePriority>(settings.max_size, settings.max_elements);
{
main_priority = std::make_unique<LRUFileCachePriority>(
settings.max_size, settings.max_elements, nullptr, cache_name);
}
else if (settings.cache_policy == "SLRU")
main_priority = std::make_unique<SLRUFileCachePriority>(settings.max_size, settings.max_elements, settings.slru_size_ratio);
{
main_priority = std::make_unique<SLRUFileCachePriority>(
settings.max_size, settings.max_elements, settings.slru_size_ratio, nullptr, nullptr, cache_name);
}
else
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Unknown cache policy: {}", settings.cache_policy);

View File

@ -28,17 +28,19 @@ SLRUFileCachePriority::SLRUFileCachePriority(
size_t max_elements_,
double size_ratio_,
LRUFileCachePriority::StatePtr probationary_state_,
LRUFileCachePriority::StatePtr protected_state_)
LRUFileCachePriority::StatePtr protected_state_,
const std::string & description_)
: IFileCachePriority(max_size_, max_elements_)
, size_ratio(size_ratio_)
, protected_queue(LRUFileCachePriority(getRatio(max_size_, size_ratio),
getRatio(max_elements_, size_ratio),
protected_state_,
"protected"))
description_ + ", protected"))
, probationary_queue(LRUFileCachePriority(getRatio(max_size_, 1 - size_ratio),
getRatio(max_elements_, 1 - size_ratio),
probationary_state_,
"probationary"))
description_ + ", probationary"))
, log(getLogger("SLRUFileCachePriority(" + description_ + ")"))
{
LOG_DEBUG(
log, "Probationary queue {} in size and {} in elements. "

View File

@ -19,7 +19,8 @@ public:
size_t max_elements_,
double size_ratio_,
LRUFileCachePriority::StatePtr probationary_state_ = nullptr,
LRUFileCachePriority::StatePtr protected_state_ = nullptr);
LRUFileCachePriority::StatePtr protected_state_ = nullptr,
const std::string & description_ = "none");
size_t getSize(const CachePriorityGuard::Lock & lock) const override;
@ -67,7 +68,7 @@ private:
double size_ratio;
LRUFileCachePriority protected_queue;
LRUFileCachePriority probationary_queue;
LoggerPtr log = getLogger("SLRUFileCachePriority");
LoggerPtr log;
void increasePriority(SLRUIterator & iterator, const CachePriorityGuard::Lock & lock);