//////////////////////////////////////////////////////////////////////////////// // Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved // Unauthorized copying of this file, via any medium is strictly prohibited. // Proprietary and confidential. //////////////////////////////////////////////////////////////////////////////// namespace zilliz { namespace milvus { namespace cache { template CacheMgr::CacheMgr() { } template CacheMgr::~CacheMgr() { } template uint64_t CacheMgr::ItemCount() const { if(cache_ == nullptr) { SERVER_LOG_ERROR << "Cache doesn't exist"; return 0; } return (uint64_t)(cache_->size()); } template bool CacheMgr::ItemExists(const std::string& key) { if(cache_ == nullptr) { SERVER_LOG_ERROR << "Cache doesn't exist"; return false; } return cache_->exists(key); } template ItemObj CacheMgr::GetItem(const std::string& key) { if(cache_ == nullptr) { SERVER_LOG_ERROR << "Cache doesn't exist"; return nullptr; } server::Metrics::GetInstance().CacheAccessTotalIncrement(); return cache_->get(key); } template void CacheMgr::InsertItem(const std::string& key, const ItemObj& data) { if(cache_ == nullptr) { SERVER_LOG_ERROR << "Cache doesn't exist"; return; } cache_->insert(key, data); server::Metrics::GetInstance().CacheAccessTotalIncrement(); } template void CacheMgr::EraseItem(const std::string& key) { if(cache_ == nullptr) { SERVER_LOG_ERROR << "Cache doesn't exist"; return; } cache_->erase(key); server::Metrics::GetInstance().CacheAccessTotalIncrement(); } template void CacheMgr::PrintInfo() { if(cache_ == nullptr) { SERVER_LOG_ERROR << "Cache doesn't exist"; return; } cache_->print(); } template void CacheMgr::ClearCache() { if(cache_ == nullptr) { SERVER_LOG_ERROR << "Cache doesn't exist"; return; } cache_->clear(); } template int64_t CacheMgr::CacheUsage() const { if(cache_ == nullptr) { SERVER_LOG_ERROR << "Cache doesn't exist"; return 0; } return cache_->usage(); } template int64_t CacheMgr::CacheCapacity() const { if(cache_ == nullptr) { SERVER_LOG_ERROR << "Cache doesn't exist"; return 0; } return cache_->capacity(); } template void CacheMgr::SetCapacity(int64_t capacity) { if(cache_ == nullptr) { SERVER_LOG_ERROR << "Cache doesn't exist"; return; } cache_->set_capacity(capacity); } } } }