Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
8fb6048e
R
redis
项目概览
Turbo码先生
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
8fb6048e
编写于
1月 31, 2018
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CG: RDB saving part 1, metadata and PEL.
上级
e76fb4ab
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
73 addition
and
1 deletion
+73
-1
src/rdb.c
src/rdb.c
+73
-1
未找到文件。
src/rdb.c
浏览文件 @
8fb6048e
...
...
@@ -642,7 +642,48 @@ int rdbLoadObjectType(rio *rdb) {
return
type
;
}
/* Save a Redis object. Returns -1 on error, number of bytes written on success. */
/* This helper function serializes a consumer group Pending Entries List (PEL)
* into the RDB file. The 'nacks' argument tells the function if also persist
* the informations about the not acknowledged message, or if to persist
* just the IDs: this is useful because for the global consumer group PEL
* we serialized the NACKs as well, but when serializing the local consumer
* PELs we just add the ID, that will be resolved inside the global PEL to
* put a reference to the same structure. */
ssize_t
rdbSaveStreamPEL
(
rio
*
rdb
,
rax
*
pel
,
int
nacks
)
{
ssize_t
n
,
nwritten
=
0
;
/* Number of entries in the PEL. */
if
((
n
=
rdbSaveLen
(
rdb
,
raxSize
(
pel
)))
==
-
1
)
return
-
1
;
nwritten
+=
n
;
/* Save each entry. */
raxIterator
ri
;
raxStart
(
&
ri
,
pel
);
raxSeek
(
&
ri
,
"^"
,
NULL
,
0
);
while
(
raxNext
(
&
ri
))
{
/* We store IDs in raw form as 128 big big endian numbers, like
* they are inside the radix tree key. */
if
((
n
=
rdbWriteRaw
(
rdb
,
ri
.
key
,
sizeof
(
streamID
)))
==
-
1
)
return
-
1
;
nwritten
+=
n
;
if
(
nacks
)
{
streamNACK
*
nack
=
ri
.
data
;
if
((
n
=
rdbSaveMillisecondTime
(
rdb
,
nack
->
delivery_time
))
==
-
1
)
return
-
1
;
nwritten
+=
n
;
if
((
n
=
rdbSaveLen
(
rdb
,
nack
->
delivery_count
))
==
-
1
)
return
-
1
;
nwritten
+=
n
;
/* We don't save the consumer name: we'll save the pending IDs
* for each consumer in the consumer PEL, and resolve the consumer
* at loading time. */
}
}
raxStop
(
&
ri
);
return
nwritten
;
}
/* Save a Redis object.
* Returns -1 on error, number of bytes written on success. */
ssize_t
rdbSaveObject
(
rio
*
rdb
,
robj
*
o
)
{
ssize_t
n
=
0
,
nwritten
=
0
;
...
...
@@ -798,6 +839,37 @@ ssize_t rdbSaveObject(rio *rdb, robj *o) {
nwritten
+=
n
;
if
((
n
=
rdbSaveLen
(
rdb
,
s
->
last_id
.
seq
))
==
-
1
)
return
-
1
;
nwritten
+=
n
;
/* The consumer groups and their clients are part of the stream
* type, so serialize every consumer group. */
/* Save the number of groups. */
if
((
n
=
rdbSaveLen
(
rdb
,
raxSize
(
s
->
cgroups
)))
==
-
1
)
return
-
1
;
nwritten
+=
n
;
/* Serialize each consumer group. */
raxStart
(
&
ri
,
s
->
cgroups
);
raxSeek
(
&
ri
,
"^"
,
NULL
,
0
);
while
(
raxNext
(
&
ri
))
{
streamCG
*
cg
=
ri
.
data
;
/* Save the consumer group name. */
if
((
n
=
rdbSaveRawString
(
rdb
,
ri
.
key
,
ri
.
key_len
))
==
-
1
)
return
-
1
;
nwritten
+=
n
;
/* Last ID. */
if
((
n
=
rdbSaveLen
(
rdb
,
cg
->
last_id
.
ms
))
==
-
1
)
return
-
1
;
nwritten
+=
n
;
if
((
n
=
rdbSaveLen
(
rdb
,
cg
->
last_id
.
seq
))
==
-
1
)
return
-
1
;
nwritten
+=
n
;
/* Save the global PEL. */
if
((
n
=
rdbSaveStreamPEL
(
rdb
,
cg
->
pel
,
1
))
==
-
1
)
return
-
1
;
nwritten
+=
n
;
/* Save the consumers of this group. */
}
raxStop
(
&
ri
);
}
else
if
(
o
->
type
==
OBJ_MODULE
)
{
/* Save a module-specific value. */
RedisModuleIO
io
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录