Skip to content

Commit

Permalink
feat: add new pika ehash cmd to pika
Browse files Browse the repository at this point in the history
1. pkhget pkhset

2. pkhexpire pkhexpireat

3. pkhexpiretime pkhpersist pkhttl

4. add  new test cases for pkhash cmd below

5. PKHSetex PKHExists PKHDel PKHLen PKHStrlen

6. PKHIncrby PKHMSet PKHMSetex PKHMGet PKHKeys

7. PKHVals PKHGetall PKHScan
  • Loading branch information
bigdaronlee163 authored and bgl committed Oct 29, 2024
1 parent b5cdb2f commit 589a5f6
Show file tree
Hide file tree
Showing 20 changed files with 5,270 additions and 828 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ link_directories("/opt/rh/gcc-toolset-13/root/lib/gcc/x86_64-redhat-linux/13")
#set(CMAKE_BUILD_TYPE "Debug")
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=thread -O0 -fno-omit-frame-pointer -fno-optimize-sibling-calls")

set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -Wall -g3 -ggdb -fno-inline -fno-builtin-memcmp")

string(TOLOWER ${CMAKE_HOST_SYSTEM_PROCESSOR} HOST_ARCH)

if(NOT CMAKE_BUILD_TYPE)
Expand Down
1 change: 1 addition & 0 deletions include/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ enum class AclCategory {
CONNECTION = (1ULL << 18),
TRANSACTION = (1ULL << 19),
SCRIPTING = (1ULL << 20),
PKHASH = (1ULL << 21),
};

enum class AclUserFlag {
Expand Down
31 changes: 26 additions & 5 deletions include/pika_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,27 @@ const std::string kCmdNameHScanx = "hscanx";
const std::string kCmdNamePKHScanRange = "pkhscanrange";
const std::string kCmdNamePKHRScanRange = "pkhrscanrange";

// PKHash
const std::string kCmdNamePKHSet = "pkhset";
const std::string kCmdNamePKHExpire = "pkhexpire";
const std::string kCmdNamePKHExpireat = "pkhexpireat";
const std::string kCmdNamePKHExpiretime = "pkhexpiretime";
const std::string kCmdNamePKHTTL = "pkhttl";
const std::string kCmdNamePKHPersist = "pkhpersist";
const std::string kCmdNamePKHGet = "pkhget";
const std::string kCmdNamePKHExists = "pkhexists";
const std::string kCmdNamePKHDel = "pkhdel";
const std::string kCmdNamePKHLen = "pkhlen";
const std::string kCmdNamePKHStrlen = "pkhstrlen";
const std::string kCmdNamePKHIncrby = "pkhincrby";
const std::string kCmdNamePKHMSet = "pkhmset";
const std::string kCmdNamePKHSetex = "pkhmsetex";
const std::string kCmdNamePKHMGet = "pkhmget";
const std::string kCmdNamePKHKeys = "pkhkeys";
const std::string kCmdNamePKHVals = "pkhvals";
const std::string kCmdNamePKHGetall = "pkhgetall";
const std::string kCmdNamePKHScan = "pkhscan";

// List
const std::string kCmdNameLIndex = "lindex";
const std::string kCmdNameLInsert = "linsert";
Expand Down Expand Up @@ -247,7 +268,6 @@ const std::string kCmdNameXInfo = "xinfo";

const std::string kClusterPrefix = "pkcluster";


/*
* If a type holds a key, a new data structure
* that uses the key will use this error
Expand Down Expand Up @@ -290,7 +310,8 @@ enum CmdFlags {
kCmdFlagsOperateKey = (1 << 19), // redis keySpace
kCmdFlagsStream = (1 << 20),
kCmdFlagsFast = (1 << 21),
kCmdFlagsSlow = (1 << 22)
kCmdFlagsSlow = (1 << 22),
kCmdFlagsPKHash = (1 << 23),
};

void inline RedisAppendContent(std::string& str, const std::string& value);
Expand Down Expand Up @@ -483,7 +504,7 @@ class CmdRes {
struct UnblockTaskArgs {
std::string key;
std::shared_ptr<DB> db;
net::DispatchThread* dispatchThread{ nullptr };
net::DispatchThread* dispatchThread{nullptr};
UnblockTaskArgs(std::string key_, std::shared_ptr<DB> db_, net::DispatchThread* dispatchThread_)
: key(std::move(key_)), db(db_), dispatchThread(dispatchThread_) {}
};
Expand Down Expand Up @@ -572,7 +593,7 @@ class Cmd : public std::enable_shared_from_this<Cmd> {
std::shared_ptr<std::string> GetResp();

void SetStage(CmdStage stage);
void SetCmdId(uint32_t cmdId){cmdId_ = cmdId;}
void SetCmdId(uint32_t cmdId) { cmdId_ = cmdId; }

virtual void DoBinlog();

Expand Down Expand Up @@ -614,7 +635,7 @@ class Cmd : public std::enable_shared_from_this<Cmd> {

private:
virtual void DoInitial() = 0;
virtual void Clear(){};
virtual void Clear() {};

Cmd& operator=(const Cmd&);
};
Expand Down
Loading

0 comments on commit 589a5f6

Please sign in to comment.