提交 713d1ec6 编写于 作者: X Xu Peng

feat(db): add cache


Former-commit-id: 2dd8078d8df484ddac54379bc6c84c015c1fc530
上级 052f7e2f
#include <easylogging++.h> #include <easylogging++.h>
#include <faiss/AutoTune.h> #include <faiss/AutoTune.h>
#include <wrapper/Index.h> #include <wrapper/Index.h>
#include <cache/CpuCacheMgr.h>
#include "FaissSerializer.h" #include "FaissSerializer.h"
...@@ -33,6 +34,12 @@ Status FaissSerializer::Serialize() { ...@@ -33,6 +34,12 @@ Status FaissSerializer::Serialize() {
return Status::OK(); return Status::OK();
} }
Status FaissSerializer::Cache() {
zilliz::vecwise::cache::CpuCacheMgr::GetInstance(
)->InsertItem(location_, std::make_shared<Index>(pIndex_));
return Status::OK();
}
} // namespace engine } // namespace engine
} // namespace vecwise } // namespace vecwise
......
...@@ -24,6 +24,8 @@ public: ...@@ -24,6 +24,8 @@ public:
virtual Status Serialize() override; virtual Status Serialize() override;
virtual Status Cache() override;
protected: protected:
std::shared_ptr<faiss::Index> pIndex_; std::shared_ptr<faiss::Index> pIndex_;
std::string location_; std::string location_;
......
...@@ -22,6 +22,8 @@ public: ...@@ -22,6 +22,8 @@ public:
virtual Status Serialize() = 0; virtual Status Serialize() = 0;
virtual Status Cache() = 0;
virtual ~Serializer() {} virtual ~Serializer() {}
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册