Skip to content

Commit

Permalink
redis-cli: added comments to split program in parts.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Feb 25, 2014
1 parent 386467a commit dcac007
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions src/redis-cli.c
Expand Up @@ -102,14 +102,18 @@ char *redisGitDirty(void);
* Utility functions
*--------------------------------------------------------------------------- */

static long long mstime(void) {
static long long ustime(void) {
struct timeval tv;
long long mst;
long long ust;

gettimeofday(&tv, NULL);
mst = ((long long)tv.tv_sec)*1000;
mst += tv.tv_usec/1000;
return mst;
ust = ((long long)tv.tv_sec)*1000000;
ust += tv.tv_usec;
return ust;
}

static long long mstime(void) {
return ustime()/1000;
}

static void cliRefreshPrompt(void) {
Expand Down Expand Up @@ -950,6 +954,10 @@ static int noninteractive(int argc, char **argv) {
return retval;
}

/*------------------------------------------------------------------------------
* Eval mode
*--------------------------------------------------------------------------- */

static int evalMode(int argc, char **argv) {
sds script = sdsempty();
FILE *fp;
Expand Down Expand Up @@ -988,6 +996,10 @@ static int evalMode(int argc, char **argv) {
return cliSendCommand(argc+3-got_comma, argv2, config.repeat);
}

/*------------------------------------------------------------------------------
* Latency and latency history modes
*--------------------------------------------------------------------------- */

#define LATENCY_SAMPLE_RATE 10 /* milliseconds. */
#define LATENCY_HISTORY_DEFAULT_INTERVAL 15000 /* milliseconds. */
static void latencyMode(void) {
Expand Down Expand Up @@ -1032,6 +1044,10 @@ static void latencyMode(void) {
}
}

/*------------------------------------------------------------------------------
* Slave mode
*--------------------------------------------------------------------------- */

/* Sends SYNC and reads the number of bytes in the payload. Used both by
* slaveMode() and getRDB(). */
unsigned long long sendSync(int fd) {
Expand Down Expand Up @@ -1095,6 +1111,10 @@ static void slaveMode(void) {
config.output = original_output;
}

/*------------------------------------------------------------------------------
* RDB transfer mode
*--------------------------------------------------------------------------- */

/* This function implements --rdb, so it uses the replication protocol in order
* to fetch the RDB file from a remote server. */
static void getRDB(void) {
Expand Down Expand Up @@ -1140,6 +1160,10 @@ static void getRDB(void) {
exit(0);
}

/*------------------------------------------------------------------------------
* Bulk import (pipe) mode
*--------------------------------------------------------------------------- */

static void pipeMode(void) {
int fd = context->fd;
long long errors = 0, replies = 0, obuf_len = 0, obuf_pos = 0;
Expand Down Expand Up @@ -1291,6 +1315,10 @@ static void pipeMode(void) {
exit(0);
}

/*------------------------------------------------------------------------------
* Find big keys
*--------------------------------------------------------------------------- */

#define TYPE_STRING 0
#define TYPE_LIST 1
#define TYPE_SET 2
Expand Down Expand Up @@ -1377,6 +1405,10 @@ static void findBigKeys(void) {
}
}

/*------------------------------------------------------------------------------
* Stats mode
*--------------------------------------------------------------------------- */

/* Return the specified INFO field from the INFO command output "info".
* A new buffer is allocated for the result, that needs to be free'd.
* If the field is not found NULL is returned. */
Expand Down Expand Up @@ -1516,6 +1548,10 @@ static void statMode() {
}
}

/*------------------------------------------------------------------------------
* Scan mode
*--------------------------------------------------------------------------- */

static void scanMode() {
redisReply *reply;
unsigned long long cur = 0;
Expand Down

0 comments on commit dcac007

Please sign in to comment.