mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
add cache classes
Former-commit-id: 9bbc325ab6b6a1916801c05e3eb08e356db38299
This commit is contained in:
parent
07b272f058
commit
dafd5a45cd
@ -4,7 +4,7 @@
|
||||
# Proprietary and confidential.
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
AUX_SOURCE_DIRECTORY(./cache cache_files)
|
||||
aux_source_directory(./cache cache_files)
|
||||
|
||||
set(vecwise_engine_src
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
|
||||
|
||||
6
cpp/src/cache/CacheMgr.cpp
vendored
6
cpp/src/cache/CacheMgr.cpp
vendored
@ -15,15 +15,15 @@ CacheMgr::CacheMgr() {
|
||||
cache_ = std::make_shared<Cache>(16, 1UL<<32);
|
||||
}
|
||||
|
||||
size_t CacheMgr::ItemCount() const {
|
||||
uint64_t CacheMgr::ItemCount() const {
|
||||
if(cache_ == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return cache_->size();
|
||||
return (uint64_t)(cache_->size());
|
||||
}
|
||||
|
||||
bool CacheMgr::IsExists(const std::string& key) {
|
||||
bool CacheMgr::ItemExists(const std::string& key) {
|
||||
if(cache_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
4
cpp/src/cache/CacheMgr.h
vendored
4
cpp/src/cache/CacheMgr.h
vendored
@ -19,9 +19,9 @@ public:
|
||||
return mgr;
|
||||
}
|
||||
|
||||
size_t ItemCount() const;
|
||||
uint64_t ItemCount() const;
|
||||
|
||||
bool IsExists(const std::string& key);
|
||||
bool ItemExists(const std::string& key);
|
||||
|
||||
DataObjPtr GetItem(const std::string& key);
|
||||
|
||||
|
||||
4
cpp/unittest/cache/CMakeLists.txt
vendored
4
cpp/unittest/cache/CMakeLists.txt
vendored
@ -5,9 +5,7 @@
|
||||
#-------------------------------------------------------------------------------
|
||||
include_directories(../../src)
|
||||
|
||||
set(cache_srcs
|
||||
../../src/cache/Cache.cpp
|
||||
../../src/cache/CacheMgr.cpp)
|
||||
aux_source_directory(../../src/cache cache_srcs)
|
||||
|
||||
set(cache_test_src
|
||||
${unittest_srcs}
|
||||
|
||||
2
cpp/unittest/cache/cache_tests.cpp
vendored
2
cpp/unittest/cache/cache_tests.cpp
vendored
@ -32,7 +32,7 @@ TEST(CacheTest, CACHE_TEST) {
|
||||
cache_mgr.InsertItem(key, MAKE_100MB_DATA);
|
||||
cache::DataObjPtr data = cache_mgr.GetItem(key);
|
||||
ASSERT_TRUE(data != nullptr);
|
||||
ASSERT_TRUE(cache_mgr.IsExists(key));
|
||||
ASSERT_TRUE(cache_mgr.ItemExists(key));
|
||||
ASSERT_EQ(data->size(), 100*1024*1024);
|
||||
|
||||
cache_mgr.EraseItem(key);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user