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
feb8d7e6
Commit
feb8d7e6
authored
Apr 16, 2010
by
Pieter Noordhuis
Browse files
rename hashReplace to hashSet
parent
16fa22f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
feb8d7e6
...
@@ -6110,7 +6110,7 @@ static int hashExists(robj *o, robj *key) {
...
@@ -6110,7 +6110,7 @@ static int hashExists(robj *o, robj *key) {
/* Add an element, discard the old if the key already exists.
/* Add an element, discard the old if the key already exists.
* Return 0 on insert and 1 on update. */
* Return 0 on insert and 1 on update. */
static
int
hash
Replace
(
robj
*
o
,
robj
*
key
,
robj
*
value
)
{
static
int
hash
Set
(
robj
*
o
,
robj
*
key
,
robj
*
value
)
{
int
update
=
0
;
int
update
=
0
;
if
(
o
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
if
(
o
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
key
=
getDecodedObject
(
key
);
key
=
getDecodedObject
(
key
);
...
@@ -6247,7 +6247,7 @@ static void hsetCommand(redisClient *c) {
...
@@ -6247,7 +6247,7 @@ static void hsetCommand(redisClient *c) {
if
((
o
=
hashLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
if
((
o
=
hashLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
hashTryConversion
(
o
,
c
->
argv
,
2
,
3
);
hashTryConversion
(
o
,
c
->
argv
,
2
,
3
);
update
=
hash
Replace
(
o
,
c
->
argv
[
2
],
c
->
argv
[
3
]);
update
=
hash
Set
(
o
,
c
->
argv
[
2
],
c
->
argv
[
3
]);
addReply
(
c
,
update
?
shared
.
czero
:
shared
.
cone
);
addReply
(
c
,
update
?
shared
.
czero
:
shared
.
cone
);
server
.
dirty
++
;
server
.
dirty
++
;
}
}
...
@@ -6260,7 +6260,7 @@ static void hsetnxCommand(redisClient *c) {
...
@@ -6260,7 +6260,7 @@ static void hsetnxCommand(redisClient *c) {
if
(
hashExists
(
o
,
c
->
argv
[
2
]))
{
if
(
hashExists
(
o
,
c
->
argv
[
2
]))
{
addReply
(
c
,
shared
.
czero
);
addReply
(
c
,
shared
.
czero
);
}
else
{
}
else
{
hash
Replace
(
o
,
c
->
argv
[
2
],
c
->
argv
[
3
]);
hash
Set
(
o
,
c
->
argv
[
2
],
c
->
argv
[
3
]);
addReply
(
c
,
shared
.
cone
);
addReply
(
c
,
shared
.
cone
);
server
.
dirty
++
;
server
.
dirty
++
;
}
}
...
@@ -6278,7 +6278,7 @@ static void hmsetCommand(redisClient *c) {
...
@@ -6278,7 +6278,7 @@ static void hmsetCommand(redisClient *c) {
if
((
o
=
hashLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
if
((
o
=
hashLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
hashTryConversion
(
o
,
c
->
argv
,
2
,
c
->
argc
-
1
);
hashTryConversion
(
o
,
c
->
argv
,
2
,
c
->
argc
-
1
);
for
(
i
=
2
;
i
<
c
->
argc
;
i
+=
2
)
{
for
(
i
=
2
;
i
<
c
->
argc
;
i
+=
2
)
{
hash
Replace
(
o
,
c
->
argv
[
i
],
c
->
argv
[
i
+
1
]);
hash
Set
(
o
,
c
->
argv
[
i
],
c
->
argv
[
i
+
1
]);
}
}
addReply
(
c
,
shared
.
ok
);
addReply
(
c
,
shared
.
ok
);
}
}
...
@@ -6308,7 +6308,7 @@ static void hincrbyCommand(redisClient *c) {
...
@@ -6308,7 +6308,7 @@ static void hincrbyCommand(redisClient *c) {
value
+=
incr
;
value
+=
incr
;
new
=
createObject
(
REDIS_STRING
,
sdscatprintf
(
sdsempty
(),
"%lld"
,
value
));
new
=
createObject
(
REDIS_STRING
,
sdscatprintf
(
sdsempty
(),
"%lld"
,
value
));
hash
Replace
(
o
,
c
->
argv
[
2
],
new
);
hash
Set
(
o
,
c
->
argv
[
2
],
new
);
decrRefCount
(
new
);
decrRefCount
(
new
);
addReplyLongLong
(
c
,
value
);
addReplyLongLong
(
c
,
value
);
server
.
dirty
++
;
server
.
dirty
++
;
...
...
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