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
68bfe993
Commit
68bfe993
authored
Nov 15, 2011
by
antirez
Browse files
HINCRBYFLOAT implemented
parent
d4a3cfed
Changes
3
Show whitespace changes
Inline
Side-by-side
src/redis.c
View file @
68bfe993
...
...
@@ -157,6 +157,7 @@ struct redisCommand redisCommandTable[] = {
{
"hmset"
,
hmsetCommand
,
-
4
,
"wm"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hmget"
,
hmgetCommand
,
-
3
,
"r"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hincrby"
,
hincrbyCommand
,
4
,
"wm"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hincrbyfloat"
,
hincrbyfloatCommand
,
4
,
"wm"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hdel"
,
hdelCommand
,
-
3
,
"w"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hlen"
,
hlenCommand
,
2
,
"r"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hkeys"
,
hkeysCommand
,
2
,
"r"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
...
...
src/redis.h
View file @
68bfe993
...
...
@@ -1104,6 +1104,7 @@ void hgetallCommand(redisClient *c);
void
hexistsCommand
(
redisClient
*
c
);
void
configCommand
(
redisClient
*
c
);
void
hincrbyCommand
(
redisClient
*
c
);
void
hincrbyfloatCommand
(
redisClient
*
c
);
void
subscribeCommand
(
redisClient
*
c
);
void
unsubscribeCommand
(
redisClient
*
c
);
void
psubscribeCommand
(
redisClient
*
c
);
...
...
src/t_hash.c
View file @
68bfe993
...
...
@@ -346,6 +346,33 @@ void hincrbyCommand(redisClient *c) {
server
.
dirty
++
;
}
void
hincrbyfloatCommand
(
redisClient
*
c
)
{
double
long
value
,
incr
;
robj
*
o
,
*
current
,
*
new
;
if
(
getLongDoubleFromObjectOrReply
(
c
,
c
->
argv
[
3
],
&
incr
,
NULL
)
!=
REDIS_OK
)
return
;
if
((
o
=
hashTypeLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
if
((
current
=
hashTypeGetObject
(
o
,
c
->
argv
[
2
]))
!=
NULL
)
{
if
(
getLongDoubleFromObjectOrReply
(
c
,
current
,
&
value
,
"hash value is not a valid float"
)
!=
REDIS_OK
)
{
decrRefCount
(
current
);
return
;
}
decrRefCount
(
current
);
}
else
{
value
=
0
;
}
value
+=
incr
;
new
=
createStringObjectFromLongDouble
(
value
);
hashTypeTryObjectEncoding
(
o
,
&
c
->
argv
[
2
],
NULL
);
hashTypeSet
(
o
,
c
->
argv
[
2
],
new
);
addReplyBulk
(
c
,
new
);
decrRefCount
(
new
);
signalModifiedKey
(
c
->
db
,
c
->
argv
[
1
]);
server
.
dirty
++
;
}
void
hgetCommand
(
redisClient
*
c
)
{
robj
*
o
,
*
value
;
unsigned
char
*
v
;
...
...
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