Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
6f0e77ca
R
redis
项目概览
别团等shy哥发育
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6f0e77ca
编写于
3月 23, 2012
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replicate HINCRBYFLOAT as HSET.
上级
7b558b1d
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
14 addition
and
11 deletion
+14
-11
src/t_hash.c
src/t_hash.c
+14
-11
未找到文件。
src/t_hash.c
浏览文件 @
6f0e77ca
...
...
@@ -135,7 +135,9 @@ int hashTypeExists(robj *o, robj *field) {
}
/* 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.
* This function will take care of incrementing the reference count of the
* retained fields and value objects. */
int
hashTypeSet
(
robj
*
o
,
robj
*
field
,
robj
*
value
)
{
int
update
=
0
;
...
...
@@ -168,30 +170,23 @@ int hashTypeSet(robj *o, robj *field, robj *value) {
zl
=
ziplistPush
(
zl
,
field
->
ptr
,
sdslen
(
field
->
ptr
),
ZIPLIST_TAIL
);
zl
=
ziplistPush
(
zl
,
value
->
ptr
,
sdslen
(
value
->
ptr
),
ZIPLIST_TAIL
);
}
o
->
ptr
=
zl
;
decrRefCount
(
field
);
decrRefCount
(
value
);
/* Check if the ziplist needs to be converted to a hash table */
if
(
hashTypeLength
(
o
)
>
server
.
hash_max_ziplist_entries
)
{
if
(
hashTypeLength
(
o
)
>
server
.
hash_max_ziplist_entries
)
hashTypeConvert
(
o
,
REDIS_ENCODING_HT
);
}
}
else
if
(
o
->
encoding
==
REDIS_ENCODING_HT
)
{
if
(
dictReplace
(
o
->
ptr
,
field
,
value
))
{
/* Insert */
incrRefCount
(
field
);
}
else
{
/* Update */
update
=
1
;
}
incrRefCount
(
value
);
}
else
{
redisPanic
(
"Unknown hash encoding"
);
}
return
update
;
}
...
...
@@ -520,7 +515,7 @@ void hincrbyCommand(redisClient *c) {
void
hincrbyfloatCommand
(
redisClient
*
c
)
{
double
long
value
,
incr
;
robj
*
o
,
*
current
,
*
new
;
robj
*
o
,
*
current
,
*
new
,
*
aux
;
if
(
getLongDoubleFromObjectOrReply
(
c
,
c
->
argv
[
3
],
&
incr
,
NULL
)
!=
REDIS_OK
)
return
;
if
((
o
=
hashTypeLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
...
...
@@ -540,9 +535,17 @@ void hincrbyfloatCommand(redisClient *c) {
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
++
;
/* Always replicate HINCRBYFLOAT as an HSET command with the final value
* in order to make sure that differences in float pricision or formatting
* will not create differences in replicas or after an AOF restart. */
aux
=
createStringObject
(
"HSET"
,
4
);
rewriteClientCommandArgument
(
c
,
0
,
aux
);
decrRefCount
(
aux
);
rewriteClientCommandArgument
(
c
,
3
,
new
);
decrRefCount
(
new
);
}
static
void
addHashFieldToReply
(
redisClient
*
c
,
robj
*
o
,
robj
*
field
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录