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
a431eb74
Commit
a431eb74
authored
Apr 28, 2009
by
antirez
Browse files
GETSET implemented
parent
b8b553c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
redis-cli.c
View file @
a431eb74
...
@@ -85,6 +85,7 @@ static struct redisCommand cmdTable[] = {
...
@@ -85,6 +85,7 @@ static struct redisCommand cmdTable[] = {
{
"smembers"
,
2
,
REDIS_CMD_INLINE
},
{
"smembers"
,
2
,
REDIS_CMD_INLINE
},
{
"incrby"
,
3
,
REDIS_CMD_INLINE
},
{
"incrby"
,
3
,
REDIS_CMD_INLINE
},
{
"decrby"
,
3
,
REDIS_CMD_INLINE
},
{
"decrby"
,
3
,
REDIS_CMD_INLINE
},
{
"getset"
,
3
,
REDIS_CMD_BULK
},
{
"randomkey"
,
1
,
REDIS_CMD_INLINE
},
{
"randomkey"
,
1
,
REDIS_CMD_INLINE
},
{
"select"
,
2
,
REDIS_CMD_INLINE
},
{
"select"
,
2
,
REDIS_CMD_INLINE
},
{
"move"
,
3
,
REDIS_CMD_INLINE
},
{
"move"
,
3
,
REDIS_CMD_INLINE
},
...
...
redis.c
View file @
a431eb74
...
@@ -356,6 +356,7 @@ static void infoCommand(redisClient *c);
...
@@ -356,6 +356,7 @@ static void infoCommand(redisClient *c);
static
void
mgetCommand
(
redisClient
*
c
);
static
void
mgetCommand
(
redisClient
*
c
);
static
void
monitorCommand
(
redisClient
*
c
);
static
void
monitorCommand
(
redisClient
*
c
);
static
void
expireCommand
(
redisClient
*
c
);
static
void
expireCommand
(
redisClient
*
c
);
static
void
getSetCommand
(
redisClient
*
c
);
/*================================= Globals ================================= */
/*================================= Globals ================================= */
...
@@ -391,6 +392,7 @@ static struct redisCommand cmdTable[] = {
...
@@ -391,6 +392,7 @@ static struct redisCommand cmdTable[] = {
{
"smembers"
,
sinterCommand
,
2
,
REDIS_CMD_INLINE
},
{
"smembers"
,
sinterCommand
,
2
,
REDIS_CMD_INLINE
},
{
"incrby"
,
incrbyCommand
,
3
,
REDIS_CMD_INLINE
},
{
"incrby"
,
incrbyCommand
,
3
,
REDIS_CMD_INLINE
},
{
"decrby"
,
decrbyCommand
,
3
,
REDIS_CMD_INLINE
},
{
"decrby"
,
decrbyCommand
,
3
,
REDIS_CMD_INLINE
},
{
"getset"
,
getSetCommand
,
3
,
REDIS_CMD_BULK
},
{
"randomkey"
,
randomkeyCommand
,
1
,
REDIS_CMD_INLINE
},
{
"randomkey"
,
randomkeyCommand
,
1
,
REDIS_CMD_INLINE
},
{
"select"
,
selectCommand
,
2
,
REDIS_CMD_INLINE
},
{
"select"
,
selectCommand
,
2
,
REDIS_CMD_INLINE
},
{
"move"
,
moveCommand
,
3
,
REDIS_CMD_INLINE
},
{
"move"
,
moveCommand
,
3
,
REDIS_CMD_INLINE
},
...
@@ -2174,6 +2176,18 @@ static void getCommand(redisClient *c) {
...
@@ -2174,6 +2176,18 @@ static void getCommand(redisClient *c) {
}
}
}
}
static
void
getSetCommand
(
redisClient
*
c
)
{
getCommand
(
c
);
if
(
dictAdd
(
c
->
db
->
dict
,
c
->
argv
[
1
],
c
->
argv
[
2
])
==
DICT_ERR
)
{
dictReplace
(
c
->
db
->
dict
,
c
->
argv
[
1
],
c
->
argv
[
2
]);
}
else
{
incrRefCount
(
c
->
argv
[
1
]);
}
incrRefCount
(
c
->
argv
[
2
]);
server
.
dirty
++
;
removeExpire
(
c
->
db
,
c
->
argv
[
1
]);
}
static
void
mgetCommand
(
redisClient
*
c
)
{
static
void
mgetCommand
(
redisClient
*
c
)
{
int
j
;
int
j
;
...
...
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