Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
70003d28
Commit
70003d28
authored
Mar 22, 2009
by
antirez
Browse files
INFO fixed, MGET implemented, redis-cli implements INFO/MGET
parent
ed9b544e
Changes
2
Show whitespace changes
Inline
Side-by-side
redis-cli.c
View file @
70003d28
...
@@ -103,7 +103,8 @@ static struct redisCommand cmdTable[] = {
...
@@ -103,7 +103,8 @@ static struct redisCommand cmdTable[] = {
{
"flushdb"
,
1
,
REDIS_CMD_INLINE
|
REDIS_CMD_RETCODEREPLY
},
{
"flushdb"
,
1
,
REDIS_CMD_INLINE
|
REDIS_CMD_RETCODEREPLY
},
{
"flushall"
,
1
,
REDIS_CMD_INLINE
|
REDIS_CMD_RETCODEREPLY
},
{
"flushall"
,
1
,
REDIS_CMD_INLINE
|
REDIS_CMD_RETCODEREPLY
},
{
"sort"
,
-
2
,
REDIS_CMD_INLINE
|
REDIS_CMD_MULTIBULKREPLY
},
{
"sort"
,
-
2
,
REDIS_CMD_INLINE
|
REDIS_CMD_MULTIBULKREPLY
},
{
"version"
,
1
,
REDIS_CMD_INLINE
|
REDIS_CMD_SINGLELINEREPLY
},
{
"info"
,
1
,
REDIS_CMD_INLINE
|
REDIS_CMD_BULKREPLY
},
{
"mget"
,
-
2
,
REDIS_CMD_INLINE
|
REDIS_CMD_MULTIBULKREPLY
},
{
NULL
,
0
,
0
}
{
NULL
,
0
,
0
}
};
};
...
...
redis.c
View file @
70003d28
...
@@ -281,6 +281,7 @@ static void flushallCommand(redisClient *c);
...
@@ -281,6 +281,7 @@ static void flushallCommand(redisClient *c);
static
void
sortCommand
(
redisClient
*
c
);
static
void
sortCommand
(
redisClient
*
c
);
static
void
lremCommand
(
redisClient
*
c
);
static
void
lremCommand
(
redisClient
*
c
);
static
void
infoCommand
(
redisClient
*
c
);
static
void
infoCommand
(
redisClient
*
c
);
static
void
mgetCommand
(
redisClient
*
c
);
/*================================= Globals ================================= */
/*================================= Globals ================================= */
...
@@ -294,6 +295,7 @@ static struct redisCommand cmdTable[] = {
...
@@ -294,6 +295,7 @@ static struct redisCommand cmdTable[] = {
{
"exists"
,
existsCommand
,
2
,
REDIS_CMD_INLINE
},
{
"exists"
,
existsCommand
,
2
,
REDIS_CMD_INLINE
},
{
"incr"
,
incrCommand
,
2
,
REDIS_CMD_INLINE
},
{
"incr"
,
incrCommand
,
2
,
REDIS_CMD_INLINE
},
{
"decr"
,
decrCommand
,
2
,
REDIS_CMD_INLINE
},
{
"decr"
,
decrCommand
,
2
,
REDIS_CMD_INLINE
},
{
"mget"
,
mgetCommand
,
-
2
,
REDIS_CMD_INLINE
},
{
"rpush"
,
rpushCommand
,
3
,
REDIS_CMD_BULK
},
{
"rpush"
,
rpushCommand
,
3
,
REDIS_CMD_BULK
},
{
"lpush"
,
lpushCommand
,
3
,
REDIS_CMD_BULK
},
{
"lpush"
,
lpushCommand
,
3
,
REDIS_CMD_BULK
},
{
"rpop"
,
rpopCommand
,
2
,
REDIS_CMD_INLINE
},
{
"rpop"
,
rpopCommand
,
2
,
REDIS_CMD_INLINE
},
...
@@ -1696,6 +1698,29 @@ static void getCommand(redisClient *c) {
...
@@ -1696,6 +1698,29 @@ static void getCommand(redisClient *c) {
}
}
}
}
static
void
mgetCommand
(
redisClient
*
c
)
{
dictEntry
*
de
;
int
j
;
addReplySds
(
c
,
sdscatprintf
(
sdsempty
(),
"%d
\r\n
"
,
c
->
argc
-
1
));
for
(
j
=
1
;
j
<
c
->
argc
;
j
++
)
{
de
=
dictFind
(
c
->
dict
,
c
->
argv
[
j
]);
if
(
de
==
NULL
)
{
addReply
(
c
,
shared
.
minus1
);
}
else
{
robj
*
o
=
dictGetEntryVal
(
de
);
if
(
o
->
type
!=
REDIS_STRING
)
{
addReply
(
c
,
shared
.
minus1
);
}
else
{
addReplySds
(
c
,
sdscatprintf
(
sdsempty
(),
"%d
\r\n
"
,(
int
)
sdslen
(
o
->
ptr
)));
addReply
(
c
,
o
);
addReply
(
c
,
shared
.
crlf
);
}
}
}
}
static
void
incrDecrCommand
(
redisClient
*
c
,
int
incr
)
{
static
void
incrDecrCommand
(
redisClient
*
c
,
int
incr
)
{
dictEntry
*
de
;
dictEntry
*
de
;
long
long
value
;
long
long
value
;
...
@@ -2790,6 +2815,7 @@ static void infoCommand(redisClient *c) {
...
@@ -2790,6 +2815,7 @@ static void infoCommand(redisClient *c) {
);
);
addReplySds
(
c
,
sdscatprintf
(
sdsempty
(),
"%d
\r\n
"
,
sdslen
(
info
)));
addReplySds
(
c
,
sdscatprintf
(
sdsempty
(),
"%d
\r\n
"
,
sdslen
(
info
)));
addReplySds
(
c
,
info
);
addReplySds
(
c
,
info
);
addReply
(
c
,
shared
.
crlf
);
}
}
/* =============================== Replication ============================= */
/* =============================== Replication ============================= */
...
...
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