Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions common/configdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,24 +244,7 @@ void ConfigDBConnector_Native::mod_config(const map<string, map<string, map<stri
map<string, map<string, map<string, string>>> ConfigDBConnector_Native::get_config()
{
auto& client = get_redis_client(m_db_name);
auto const& keys = client.keys("*");
map<string, map<string, map<string, string>>> 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<map<string, string>>(key);

if (!entry.empty())
{
data[table_name][row] = entry;
}
}
return data;
return client.getall();
}

std::string ConfigDBConnector_Native::getKeySeparator() const
Expand Down
23 changes: 23 additions & 0 deletions common/dbconnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,3 +905,26 @@ void DBConnector::del(const std::vector<std::string>& keys)

pipe.flush();
}

map<string, map<string, map<string, string>>> DBConnector::getall()
{
const string separator = SonicDBConfig::getSeparator(this);
auto const& keys = this->keys("*");
map<string, map<string, map<string, string>>> 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<map<string, string>>(key);

if (!entry.empty())
{
data[table_name][row] = entry;
}
}
return data;
}
1 change: 1 addition & 0 deletions common/dbconnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class DBConnector : public RedisContext

bool flushdb();

std::map<std::string, std::map<std::string, std::map<std::string, std::string>>> getall();
private:
void setNamespace(const std::string &netns);

Expand Down