diff --git a/common/configdb.cpp b/common/configdb.cpp index 2d733f9f6..ececb2d3f 100644 --- a/common/configdb.cpp +++ b/common/configdb.cpp @@ -244,24 +244,7 @@ void ConfigDBConnector_Native::mod_config(const map>> ConfigDBConnector_Native::get_config() { auto& client = get_redis_client(m_db_name); - auto const& keys = client.keys("*"); - map>> data; - for (string key: keys) - { - size_t pos = key.find(m_table_name_separator); - if (pos == string::npos) { - continue; - } - string table_name = key.substr(0, pos); - string row = key.substr(pos + 1); - auto const& entry = client.hgetall>(key); - - if (!entry.empty()) - { - data[table_name][row] = entry; - } - } - return data; + return client.getall(); } std::string ConfigDBConnector_Native::getKeySeparator() const diff --git a/common/dbconnector.cpp b/common/dbconnector.cpp index ac17928a5..d58077818 100755 --- a/common/dbconnector.cpp +++ b/common/dbconnector.cpp @@ -905,3 +905,26 @@ void DBConnector::del(const std::vector& keys) pipe.flush(); } + +map>> DBConnector::getall() +{ + const string separator = SonicDBConfig::getSeparator(this); + auto const& keys = this->keys("*"); + map>> data; + for (string key: keys) + { + size_t pos = key.find(separator); + if (pos == string::npos) { + continue; + } + string table_name = key.substr(0, pos); + string row = key.substr(pos + 1); + auto const& entry = this->hgetall>(key); + + if (!entry.empty()) + { + data[table_name][row] = entry; + } + } + return data; +} \ No newline at end of file diff --git a/common/dbconnector.h b/common/dbconnector.h index eb37a6e83..8a70a2cfb 100644 --- a/common/dbconnector.h +++ b/common/dbconnector.h @@ -248,6 +248,7 @@ class DBConnector : public RedisContext bool flushdb(); + std::map>> getall(); private: void setNamespace(const std::string &netns);