feat: add SCANPREFIX/KEYSPREFIX/SCANRANGE/KEYSRANGE
This commit is contained in:
@@ -26,6 +26,10 @@ typedef enum {
|
||||
KVS_CMD_SETEX,
|
||||
KVS_CMD_MOD,
|
||||
KVS_CMD_EXIST,
|
||||
KVS_CMD_SCANPREFIX,
|
||||
KVS_CMD_KEYSPREFIX,
|
||||
KVS_CMD_SCANRANGE,
|
||||
KVS_CMD_KEYSRANGE,
|
||||
// rbtree
|
||||
KVS_CMD_RSET,
|
||||
KVS_CMD_RGET,
|
||||
@@ -62,12 +66,20 @@ typedef enum resp_type_e {
|
||||
RESP_T_INTEGER,
|
||||
RESP_T_BULK_STR,
|
||||
RESP_T_NIL, /* nil bulk string ($-1\r\n) */
|
||||
RESP_T_ARRAY,
|
||||
} resp_type_t;
|
||||
|
||||
typedef struct resp_array_s {
|
||||
resp_slice_t *items;
|
||||
uint32_t count;
|
||||
int owns_items;
|
||||
} resp_array_t;
|
||||
|
||||
typedef struct resp_value_s {
|
||||
resp_type_t type;
|
||||
int64_t i64; /* for integer */
|
||||
resp_slice_t bulk; /* for simple/error/bulk string (bytes) */
|
||||
resp_array_t array; /* for arrays */
|
||||
} resp_value_t;
|
||||
|
||||
/* ----------------- parsing ----------------- */
|
||||
@@ -86,6 +98,8 @@ resp_value_t resp_error(const char *s); /* -s\r\n */
|
||||
resp_value_t resp_int(int64_t x); /* :x\r\n */
|
||||
resp_value_t resp_bulk(const uint8_t *p, uint32_t n); /* $n\r\n...\r\n */
|
||||
resp_value_t resp_nil(void); /* $-1\r\n */
|
||||
resp_value_t resp_array(resp_slice_t *items, uint32_t count, int owns_items);
|
||||
void resp_value_release(resp_value_t *v);
|
||||
|
||||
/* ----------------- dispatcher ----------------- */
|
||||
/* Execute one command and return a RESP value.
|
||||
|
||||
Reference in New Issue
Block a user