Analysis of the Redis source code for nearly 1 months, but also to the most core, closest to the beginning of the system, I named him the main directory, which included 2 important documents, REDIS-CLI and Redis files, 1 represents the client's execution file, 1 represents the service-side file, these 2 are also the system's most core modules, so I put him down to main main program module, the main program module is also my Learning Redis the last module, here will be able to see all the features I saw before the traces of all the modules. Because the code in the main module is much more, so I chose a batch of learning, so today I mainly put the inside of the API method to pull out, the redis-cli of things, did an anatomy.
Just beginning to think REDIS-CLI. is the abbreviation of redis-client, but in fact he means:
/* Redis CLI (
command line interface) * Command-Line interface
So, he is directly responsive to the operation of the Redis under the Black Window command. In this file, you define the Redis context, configure the information structure, and a bunch of APIs, which are roughly the same:
/* Redis context
/static rediscontext *context;
/* REDIS configuration structure body/
static struct config
Mainly behind the various APIs, do not rush to see the method, because the method is really too much, first we learn to classify: The following is a map I do;
The module is still quite a lot of bar above are the expression form of English, in the follow-up analysis, I will be a module to do the study, such as the first Utility functions is the meaning of the general method, and what the following methods and so on. All the APIs in REDIS-CLI are released below:
/ * Utility functions * /
static long long ustime (void)
static long long mstime (void)
static void cliRefreshPrompt (void)
static sds cliVersion (void)
static void cliInitHelp (void)
static void cliOutputCommandHelp (struct commandHelp * help, int group)
static void cliOutputGenericHelp (void)
static void cliOutputHelp (int argc, char ** argv)
static void completionCallback (const char * buf, linenoiseCompletions * lc)
static int cliAuth ()
static int cliSelect ()
static int cliConnect (int force)
static void cliPrintContextError (void)
static sds cliFormatReplyTTY (redisReply * r, char * prefix)
static sds cliFormatReplyRaw (redisReply * r)
static sds cliFormatReplyCSV (redisReply * r)
static int cliReadReply (int output_raw_strings)
static int cliSendCommand (int argc, char ** argv, int repeat)
static redisReply * reconnectingInfo (void)
The
/ * User interface * /
static int parseOptions (int argc, char ** argv)
static sds readArgFromStdin (void)
static void usage (void)
static char ** convertToSds (int count, char ** args)
static void repl (void)
static int noninteractive (int argc, char ** argv)
The
/ * Eval mode Eval mode * /
static int evalMode (int argc, char ** argv)
The
/ * Latency and latency history modes
static void latencyMode (void)
/ * Slave mode * /
unsigned long long sendSync (int fd)
static void slaveMode (void)
/ * RDB transfer mode * /
static void getRDB (void)
/ * Bulk import (pipe) mode * /
static void pipeMode (void)
The
/ * Find big keys * /
static redisReply * sendScan (unsigned long long * it)
static int getDbSize (void)
static int toIntType (char * key, char * type)
static void getKeyTypes (redisReply * keys, int * types)
static void getKeySizes (redisReply * keys, int * types, unsigned long long * sizes)
static void findBigKeys (void)
The
/ * Stats mode * /
static char * getInfoField (char * info, char * field)
static long getLongInfoField (char * info, char * field)
void bytesToHuman (char * s, long long n)
static void statMode (void)
The
/ * Scan mode * /
static void scanMode (void)
/ * Intrisic latency mode * /
unsigned long compute_something_fast (void)
static void intrinsicLatencyModeStop (int s)
static void intrinsicLatencyMode (void)
/ * Program main () * /
int main (int argc, char ** argv)