parent
f20f5ad102
commit
66192a0052
@ -1257,6 +1257,15 @@ int __redisAppendCommand(redisContext *c, char *cmd, size_t len) {
|
|||||||
return REDIS_OK;
|
return REDIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int redisAppendFormattedCommand(redisContext *c, char *format, size_t len) {
|
||||||
|
|
||||||
|
if (__redisAppendCommand(c, format, len) != REDIS_OK) {
|
||||||
|
return REDIS_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return REDIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
int redisvAppendCommand(redisContext *c, const char *format, va_list ap) {
|
int redisvAppendCommand(redisContext *c, const char *format, va_list ap) {
|
||||||
char *cmd;
|
char *cmd;
|
||||||
int len;
|
int len;
|
||||||
|
@ -194,6 +194,10 @@ int redisBufferWrite(redisContext *c, int *done);
|
|||||||
int redisGetReply(redisContext *c, void **reply);
|
int redisGetReply(redisContext *c, void **reply);
|
||||||
int redisGetReplyFromReader(redisContext *c, void **reply);
|
int redisGetReplyFromReader(redisContext *c, void **reply);
|
||||||
|
|
||||||
|
/* Write a formatted command to the output buffer. Use these functions in blocking mode
|
||||||
|
* to get a pipeline of commands. */
|
||||||
|
int redisAppendFormattedCommand(redisContext *c, char *format, size_t len);
|
||||||
|
|
||||||
/* Write a command to the output buffer. Use these functions in blocking mode
|
/* Write a command to the output buffer. Use these functions in blocking mode
|
||||||
* to get a pipeline of commands. */
|
* to get a pipeline of commands. */
|
||||||
int redisvAppendCommand(redisContext *c, const char *format, va_list ap);
|
int redisvAppendCommand(redisContext *c, const char *format, va_list ap);
|
||||||
|
23
test.c
23
test.c
@ -217,6 +217,28 @@ static void test_format_commands(void) {
|
|||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_append_formatted_commands(struct config config) {
|
||||||
|
redisContext *c;
|
||||||
|
redisReply *reply;
|
||||||
|
char *cmd;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
c = connect(config);
|
||||||
|
|
||||||
|
test("Append format command: ");
|
||||||
|
|
||||||
|
len = redisFormatCommand(&cmd, "SET foo bar");
|
||||||
|
|
||||||
|
test_cond(redisAppendFormattedCommand(c, cmd, len) == REDIS_OK);
|
||||||
|
|
||||||
|
assert(redisGetReply(c, (void*)&reply) == REDIS_OK);
|
||||||
|
|
||||||
|
free(cmd);
|
||||||
|
freeReplyObject(reply);
|
||||||
|
|
||||||
|
disconnect(c, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static void test_reply_reader(void) {
|
static void test_reply_reader(void) {
|
||||||
redisReader *reader;
|
redisReader *reader;
|
||||||
void *reply;
|
void *reply;
|
||||||
@ -686,6 +708,7 @@ int main(int argc, char **argv) {
|
|||||||
test_blocking_connection(cfg);
|
test_blocking_connection(cfg);
|
||||||
test_blocking_io_errors(cfg);
|
test_blocking_io_errors(cfg);
|
||||||
test_invalid_timeout_errors(cfg);
|
test_invalid_timeout_errors(cfg);
|
||||||
|
test_append_formatted_commands(cfg);
|
||||||
if (throughput) test_throughput(cfg);
|
if (throughput) test_throughput(cfg);
|
||||||
|
|
||||||
printf("\nTesting against Unix socket connection (%s):\n", cfg.unix.path);
|
printf("\nTesting against Unix socket connection (%s):\n", cfg.unix.path);
|
||||||
|
Loading…
Reference in New Issue
Block a user