replication.c — 主从复制
源文件:src/replication.c · 共 5458 行 C 代码
模块职责
PSYNC/SYNC 协议、复制积压缓冲、命令传播。
文件头注释
/* Asynchronous replication implementation.
*
* Copyright (c) 2009-Present, Redis Ltd.
* All rights reserved.
*
* Copyright (c) 2024-present, Valkey contributors.
* All rights reserved.
*
* Licensed under your choice of (a) the Redis Source Available License 2.0
* (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the
* GNU Affero General Public License v3 (AGPLv3).
*
* Portions of this file are available under BSD3 terms; see REDISCONTRIBUTIONS for more information.
*/
主要数据结构与函数
- 数据结构:见
src/replication.h同名头文件 - 关键函数:通过
grep -nE '^(void|int|robj\*|sds|list|dict|client|server)' src/replication.c检索
阅读路径建议
- 先看
replication.h头文件了解对外接口 - 再读本文件顶部
#include列表确认依赖 - 找
^[a-z_]+Init\(类入口函数作为切入点