Skip to content

Commit

Permalink
FIX: incorrect command name, flushall=>flushdb
Browse files Browse the repository at this point in the history
  • Loading branch information
git-hulk committed Aug 21, 2019
1 parent 25b4546 commit 99fccfe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/redis_cmd.cc
Expand Up @@ -118,12 +118,12 @@ class CommandKeys : public Commander {
}
};

class CommandFlushAll : public Commander {
class CommandFlushDB : public Commander {
public:
CommandFlushAll() : Commander("flushall", 1, false) {}
CommandFlushDB() : Commander("flushdb", 1, false) {}
Status Execute(Server *svr, Connection *conn, std::string *output) override {
Redis::Database redis(svr->storage_, conn->GetNamespace());
rocksdb::Status s = redis.FlushAll();
rocksdb::Status s = redis.FlushDB();
LOG(WARNING) << "DB keys in namespce: " << conn->GetNamespace()
<< " was flused, addr: " << conn->GetAddr();
if (s.ok()) {
Expand Down Expand Up @@ -3229,9 +3229,9 @@ std::map<std::string, CommanderFactory> command_table = {
[]() -> std::unique_ptr<Commander> {
return std::unique_ptr<Commander>(new CommandKeys);
}},
{"flushall",
{"flushdb",
[]() -> std::unique_ptr<Commander> {
return std::unique_ptr<Commander>(new CommandFlushAll);
return std::unique_ptr<Commander>(new CommandFlushDB);
}},
{"dbsize",
[]() -> std::unique_ptr<Commander> {
Expand Down
2 changes: 1 addition & 1 deletion src/redis_db.cc
Expand Up @@ -237,7 +237,7 @@ rocksdb::Status Database::RandomKey(const std::string &cursor, std::string *key)
return rocksdb::Status::OK();
}

rocksdb::Status Database::FlushAll() {
rocksdb::Status Database::FlushDB() {
std::string prefix;
AppendNamespacePrefix("", &prefix);
LatestSnapShot ss(db_);
Expand Down
2 changes: 1 addition & 1 deletion src/redis_db.h
Expand Up @@ -19,7 +19,7 @@ class Database {
rocksdb::Status TTL(const Slice &user_key, int *ttl);
rocksdb::Status Type(const Slice &user_key, RedisType *type);
rocksdb::Status Dump(const Slice &user_key, std::vector<std::string> *infos);
rocksdb::Status FlushAll();
rocksdb::Status FlushDB();
void GetKeyNumStats(const std::string &prefix, KeyNumStats *stats);
void Keys(std::string prefix, std::vector<std::string> *keys = nullptr, KeyNumStats *stats = nullptr);
rocksdb::Status Scan(const std::string &cursor,
Expand Down

0 comments on commit 99fccfe

Please sign in to comment.