Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
02ae6cb0
Commit
02ae6cb0
authored
Feb 25, 2014
by
antirez
Browse files
redis-cli: added comments to split program in parts.
parent
fe051120
Changes
1
Show whitespace changes
Inline
Side-by-side
src/redis-cli.c
View file @
02ae6cb0
...
@@ -102,14 +102,18 @@ char *redisGitDirty(void);
...
@@ -102,14 +102,18 @@ char *redisGitDirty(void);
* Utility functions
* Utility functions
*--------------------------------------------------------------------------- */
*--------------------------------------------------------------------------- */
static
long
long
m
stime
(
void
)
{
static
long
long
u
stime
(
void
)
{
struct
timeval
tv
;
struct
timeval
tv
;
long
long
m
st
;
long
long
u
st
;
gettimeofday
(
&
tv
,
NULL
);
gettimeofday
(
&
tv
,
NULL
);
mst
=
((
long
long
)
tv
.
tv_sec
)
*
1000
;
ust
=
((
long
long
)
tv
.
tv_sec
)
*
1000000
;
mst
+=
tv
.
tv_usec
/
1000
;
ust
+=
tv
.
tv_usec
;
return
mst
;
return
ust
;
}
static
long
long
mstime
(
void
)
{
return
ustime
()
/
1000
;
}
}
static
void
cliRefreshPrompt
(
void
)
{
static
void
cliRefreshPrompt
(
void
)
{
...
@@ -949,6 +953,10 @@ static int noninteractive(int argc, char **argv) {
...
@@ -949,6 +953,10 @@ static int noninteractive(int argc, char **argv) {
return
retval
;
return
retval
;
}
}
/*------------------------------------------------------------------------------
* Eval mode
*--------------------------------------------------------------------------- */
static
int
evalMode
(
int
argc
,
char
**
argv
)
{
static
int
evalMode
(
int
argc
,
char
**
argv
)
{
sds
script
=
sdsempty
();
sds
script
=
sdsempty
();
FILE
*
fp
;
FILE
*
fp
;
...
@@ -987,6 +995,10 @@ static int evalMode(int argc, char **argv) {
...
@@ -987,6 +995,10 @@ static int evalMode(int argc, char **argv) {
return
cliSendCommand
(
argc
+
3
-
got_comma
,
argv2
,
config
.
repeat
);
return
cliSendCommand
(
argc
+
3
-
got_comma
,
argv2
,
config
.
repeat
);
}
}
/*------------------------------------------------------------------------------
* Latency and latency history modes
*--------------------------------------------------------------------------- */
#define LATENCY_SAMPLE_RATE 10
/* milliseconds. */
#define LATENCY_SAMPLE_RATE 10
/* milliseconds. */
#define LATENCY_HISTORY_DEFAULT_INTERVAL 15000
/* milliseconds. */
#define LATENCY_HISTORY_DEFAULT_INTERVAL 15000
/* milliseconds. */
static
void
latencyMode
(
void
)
{
static
void
latencyMode
(
void
)
{
...
@@ -1031,6 +1043,10 @@ static void latencyMode(void) {
...
@@ -1031,6 +1043,10 @@ static void latencyMode(void) {
}
}
}
}
/*------------------------------------------------------------------------------
* Slave mode
*--------------------------------------------------------------------------- */
/* Sends SYNC and reads the number of bytes in the payload. Used both by
/* Sends SYNC and reads the number of bytes in the payload. Used both by
* slaveMode() and getRDB(). */
* slaveMode() and getRDB(). */
unsigned
long
long
sendSync
(
int
fd
)
{
unsigned
long
long
sendSync
(
int
fd
)
{
...
@@ -1094,6 +1110,10 @@ static void slaveMode(void) {
...
@@ -1094,6 +1110,10 @@ static void slaveMode(void) {
config
.
output
=
original_output
;
config
.
output
=
original_output
;
}
}
/*------------------------------------------------------------------------------
* RDB transfer mode
*--------------------------------------------------------------------------- */
/* This function implements --rdb, so it uses the replication protocol in order
/* This function implements --rdb, so it uses the replication protocol in order
* to fetch the RDB file from a remote server. */
* to fetch the RDB file from a remote server. */
static
void
getRDB
(
void
)
{
static
void
getRDB
(
void
)
{
...
@@ -1139,6 +1159,10 @@ static void getRDB(void) {
...
@@ -1139,6 +1159,10 @@ static void getRDB(void) {
exit
(
0
);
exit
(
0
);
}
}
/*------------------------------------------------------------------------------
* Bulk import (pipe) mode
*--------------------------------------------------------------------------- */
static
void
pipeMode
(
void
)
{
static
void
pipeMode
(
void
)
{
int
fd
=
context
->
fd
;
int
fd
=
context
->
fd
;
long
long
errors
=
0
,
replies
=
0
,
obuf_len
=
0
,
obuf_pos
=
0
;
long
long
errors
=
0
,
replies
=
0
,
obuf_len
=
0
,
obuf_pos
=
0
;
...
@@ -1290,6 +1314,10 @@ static void pipeMode(void) {
...
@@ -1290,6 +1314,10 @@ static void pipeMode(void) {
exit
(
0
);
exit
(
0
);
}
}
/*------------------------------------------------------------------------------
* Find big keys
*--------------------------------------------------------------------------- */
#define TYPE_STRING 0
#define TYPE_STRING 0
#define TYPE_LIST 1
#define TYPE_LIST 1
#define TYPE_SET 2
#define TYPE_SET 2
...
@@ -1400,6 +1428,10 @@ static void findBigKeys(void) {
...
@@ -1400,6 +1428,10 @@ static void findBigKeys(void) {
exit
(
0
);
exit
(
0
);
}
}
/*------------------------------------------------------------------------------
* Stats mode
*--------------------------------------------------------------------------- */
/* Return the specified INFO field from the INFO command output "info".
/* 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.
* A new buffer is allocated for the result, that needs to be free'd.
* If the field is not found NULL is returned. */
* If the field is not found NULL is returned. */
...
@@ -1539,6 +1571,10 @@ static void statMode() {
...
@@ -1539,6 +1571,10 @@ static void statMode() {
}
}
}
}
/*------------------------------------------------------------------------------
* Scan mode
*--------------------------------------------------------------------------- */
static
void
scanMode
()
{
static
void
scanMode
()
{
redisReply
*
reply
;
redisReply
*
reply
;
unsigned
long
long
cur
=
0
;
unsigned
long
long
cur
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment