mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
Add support for MULTI/EXEC.
This commit is contained in:
parent
e3c7f0027f
commit
6fa246220b
12
redis-cli.c
12
redis-cli.c
@ -138,6 +138,9 @@ static struct redisCommand cmdTable[] = {
|
|||||||
{"mset",-3,REDIS_CMD_MULTIBULK},
|
{"mset",-3,REDIS_CMD_MULTIBULK},
|
||||||
{"msetnx",-3,REDIS_CMD_MULTIBULK},
|
{"msetnx",-3,REDIS_CMD_MULTIBULK},
|
||||||
{"monitor",1,REDIS_CMD_INLINE},
|
{"monitor",1,REDIS_CMD_INLINE},
|
||||||
|
{"multi",1,REDIS_CMD_INLINE},
|
||||||
|
{"exec",1,REDIS_CMD_MULTIBULK},
|
||||||
|
{"discard",1,REDIS_CMD_INLINE},
|
||||||
{NULL,0,0}
|
{NULL,0,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -155,14 +158,16 @@ static struct redisCommand *lookupCommand(char *name) {
|
|||||||
|
|
||||||
static int cliConnect(void) {
|
static int cliConnect(void) {
|
||||||
char err[ANET_ERR_LEN];
|
char err[ANET_ERR_LEN];
|
||||||
int fd;
|
static int fd = ANET_ERR;
|
||||||
|
|
||||||
|
if (fd == ANET_ERR) {
|
||||||
fd = anetTcpConnect(err,config.hostip,config.hostport);
|
fd = anetTcpConnect(err,config.hostip,config.hostport);
|
||||||
if (fd == ANET_ERR) {
|
if (fd == ANET_ERR) {
|
||||||
fprintf(stderr,"Connect: %s\n",err);
|
fprintf(stderr, "Could not connect to Redis at %s:%d: %s", config.hostip, config.hostport, err);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
anetTcpNoDelay(NULL,fd);
|
anetTcpNoDelay(NULL,fd);
|
||||||
|
}
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +287,6 @@ static int selectDb(int fd) {
|
|||||||
if (type <= 0 || type != '+') return 1;
|
if (type <= 0 || type != '+') return 1;
|
||||||
retval = cliReadSingleLineReply(fd,1);
|
retval = cliReadSingleLineReply(fd,1);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
close(fd);
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -350,11 +354,9 @@ static int cliSendCommand(int argc, char **argv) {
|
|||||||
|
|
||||||
retval = cliReadReply(fd);
|
retval = cliReadReply(fd);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
close(fd);
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(fd);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user