// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. 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); } } // namespace cache } // namespace milvus