01 - 使用VS Code调试Redis源码

如何在 VSCode 去调试 Redis源码 学习使用 Redis 时,从 GitHub 下载 Redis 源码是个不错的选择。在下载后,通过创建 task.json 和 launch.json 两个文件,可以方便地在本地进行 Redis 的编译、运行和调试。通过这些步骤,你可以更好地理解 Redis 的内部实现,并快速上手使用 Redis。 阅读详情

系列文章目录

01 - 使用VS Code调试Redis源码
02 - Redis源码结构介绍



为什么要阅读Redis源码

这两年Redis已经取代Mysql成为我工作中最常接触的基础组件了。但使用的越多,疑惑之处也越多。

首先是高可用,sentinel机制究竟是什么样的?Redis实例上线下线的过程中能够保证数据不丢失么?

其次是各个数据结构的细节,比如一个SET能够容纳多少数据?会不会在达到某个阈值之后性能断崖式下降?

第三是持久化机制,在生产中遇到了执行RDB导致Redis主从切换,所以特别需要了解其执行细节。

当然还有许多其他疑问不一一列举了。虽然网上也有很多文章介绍这些功能以及原理,但我觉得深入源码之后才能知其所以然,再遇到问题就能从更本质的角度去分析。

以上就是我开始阅读Redis源码的缘由。

参考资料

首先是《Redis设计与实现》一书,深度🌟🌟🌟,广度🌟🌟🌟🌟。我认为可以大致翻阅一遍,之后将其作为工具书,想了解哪块的知识就去对应的章节看。

其次是一门课程Redis 源码剖析与实战,在写阅读笔记的时候我还没学完。从我读到一半的体验来看,每一章节的信息量都很大,但整体来看还是显得零散。可能是这类课程的通病吧,每一章都必须要对应一个知识点。

最后是《C Primer Plus》。因为一直以来主力语言是Java,对于C的语法,尤其是指针这些知识完全陌生,还有C的编译调试也没有概念。这本书正好用来作为学习C语言的参考。

还有一些博文、教程会在具体的篇目中单独列出来。

准备调试环境

无论是看的书还是课程,上来就直接都是直接看源码了,但我希望能够debug源码,看执行一个命令的时候函数到底是怎样跳转的才能更容易理解源码。

下载源码

我使用的 redis-3.0-annotated是《Redis设计与实现》一书的配套材料,虽然当前(2022年5月份)Redis 7.0已经发布,但3.0版本已基本包含了Redis重要功能。相比于官方源码,这个仓库的代码加上了中文注释,阅读代码会更容易。

git clone https://github.com/huangz1990/redis-3.0-annotated.git

在VS Code中配置运行环境

  1. 首先确认VS Code已安装 C/C++、C/C++ Extension Pack 插件

  2. 添加配置Run -> Add Configuration

Windows免安装使用Claude Code的三种合规方案 免安装运行AI编程工具是Windows开发者高频需求,其本质是绕过系统级安装、避免注册表写入与管理员权限依赖,实现解压即用或零依赖调用。技术原理上,核心在于利用VS Code便携模式、浏览器Service Worker代理机制及npx按需执行特性,合法复用Anthropic官方API(v1/messages)与网页端session token(anthropic-sid)。这类方案不涉及破解或模拟登录,具备强安全性与IT审计合规性,广泛适用于受限办公环境、客户现场演示、CI/CD自动化及临时开发场景。本文聚 阅读详情

相关推荐

Codestral 25.01实战指南:专为开发者工作流优化的代码补全引擎

代码补全引擎是现代IDE的核心能力之一,其本质是基于上下文理解与语言建模的实时推理系统。相比通用大模型,专业级代码补全工具更强调低延迟响应、高精度上下文感知和对真实工程场景(如错误诊断、重构缝合)的深度适配。Codestral 25.01正是这一技术路径的典型代表——它放弃参数规模竞赛,转而通过FIM(Fill-in-the-Middle)架构、重写tokenizer及工作区级上下文注入,实现对Python/JS等主流语言的语义级理解。其价值不在于生成炫技代码,而在于降低开发者在调试、阅读遗留代码、跨文件协

478

OpenCLI:基于Node.js与Chrome调试协议的本地开发增强层

OpenCLI 是一种融合命令行能力与浏览器交互的新型开发工具,其核心原理是利用 Chrome DevTools Protocol(CDP)实现 DOM 操作反向注入,并通过 Node.js 后端服务调度本地系统命令。这种 CLI 驱动+前端协同的架构,突破了传统 Chrome 扩展在文件系统访问、进程调用和跨工具集成上的权限限制,具备高度可审计性与工程可控性。典型应用场景包括 SQL 一键执行、VS Code 调试数据可视化、Markdown 代码块自动高亮等轻量级自动化工作流。作为不依赖 Chrome

weixin_30394981的博客 395

Claude Code 安装配置核心原理:CLI+MCP混合架构详解

Claude Code 并非传统VS Code插件,而是一种前端UI与本地CLI进程协同工作的混合架构AI编程助手。其核心依赖Model Context Protocol(MCP)协议实现VS Code扩展与后台守护进程的实时通信,技术本质是‘图形遥控器+本地推理引擎’的分离设计。这种架构带来显著技术价值:保障上下文安全性、支持Git状态感知、实现跨命令行环境复用。典型应用场景包括企业内网AI编码、多项目并行开发、Jupyter Notebook智能补全等。理解CLI先行、MCP服务绑定、环境变量继承这三层

weixin_30565199的博客 410

Claude Code本地部署全指南:macOS/Windows避坑实战

Claude Code作为基于Claude大模型的代码智能体(Code Agent),其核心价值在于理解上下文、自动补全、调试与重构,但并非开箱即用的桌面应用。它依赖本地运行环境(如Node.js、Git、Python)与外部API服务协同工作,技术原理上属于‘Electron壳+远程推理’架构,具备高度可配置性与企业级可控性。这种设计赋予开发者对模型选型、API路由、token策略和安全边界的完全掌控权,特别适用于受网络限制、需私有化部署或强调成本透明的工程场景。本文聚焦真实落地障碍,覆盖macOS Ap

weixin_30394981的博客 615

Cursor中Claude Code插件深度配置与排错指南

Claude Code并非即装即用的智能补全工具,而是基于Anthropic API的轻量级AI编程协作者,其能力边界由网络延迟、Cursor定制化运行时(Rust+Electron)及第三方插件cc-switch的上下文处理机制共同决定。理解其不托管模型、依赖系统环境变量、需手动校验API连通性等底层原理,是实现稳定集成的技术前提。该方案适用于需要在Cursor中构建低延迟、高可控AI编码工作流的工程师,尤其适合金融、企业级开发等对安全与可追溯性要求严格的场景。

weixin_33769125的博客 476

Claude Code本地代理接入国产大模型技术解析

大语言模型协议兼容性是跨平台集成的核心挑战,涉及API网关、请求格式转换与流式响应适配等底层机制。Anthropic的Claude Code插件采用严格封闭协议,其/v1/messages路径、x-api-key认证及tool_use结构均不可绕过,因此‘免费接入’Kimi、DeepSeek等国产模型并非API替换,而是构建本地反向代理实现协议翻译与语义还原。该方案需精准模拟TLS证书校验、anthropic-version版本头、system字段处理及SSE事件流封装,技术价值在于打破厂商锁定,支撑IDE

weixin_30268921的博客 404

Claude Code API集成:构建语义路由中枢的工程实践

API集成是AI编码助手迈向生产闭环的关键能力,其本质是模型推理与外部服务在语义层的协同。传统‘配置API’思路失效于上下文限制、协议隔离与安全沙箱三大硬约束;真正可行的路径是解耦为意图理解、参数生成与可信执行三层架构。本文聚焦Claude Code这一典型封闭型AI编码工具,揭示如何通过轻量代理+语义路由器+可信执行器,在不修改客户端的前提下,实现安全、可审计、可扩展的API调度能力。核心突破在于将自然语言指令转化为结构化调用,并让Claude专注‘理解业务意图’而非‘编写HTTP请求’,从而支撑SQL生

weixin_34184561的博客 413

SEED-VIG数据集实战:5步搞定驾驶员疲劳检测模型(附Python代码)

本文提供了一份基于SEED-VIG数据集的驾驶员疲劳检测模型实战指南。通过五个核心步骤——数据准备、特征提取、模型训练、优化评估及部署思路,详细讲解了如何利用脑电信号构建分类器,并附有完整的Python代码,帮助开发者快速上手这一智能座舱关键技术。

w1x2y3的博客 263

uni-app刮奖

uni-app的刮奖效果,要注意的点: 1.小程序的canvas层级问题(可用cover-view规避) 2.不能操作dom 以下是uni-app刮奖效果的代码: <template> <!-- 刮奖 --> <view v-else class="scratch"> <view class="box"> &lt...

qq_40101922的博客 4307

别再只用GPS了!用Android手机传感器实现室内步行轨迹记录(避坑指南)

本文详细介绍了如何利用Android手机传感器(如加速度计、陀螺仪和磁力计)实现室内步行轨迹记录,克服GPS在室内的局限性。通过传感器数据采集、步态检测、航向估计和轨迹绘制等步骤,结合避坑指南和优化技巧,帮助开发者高效构建室内定位应用。

weixin_26821003的博客 274

变色龙哈希函数 Chameleon Hash 可变型区块链

哈希函数 Hash: 众所周知,区块链有着极其优秀的安全性就是因为其充分使用了哈希函数。 哈希简单用一句话来讲,就是:将任意长度输入的字串可转换成一个固定长度的字串,通过原始字串可以很容易地算出转换后的字串,通过转换后的字串很难还原出原始字串。 哈希函数特征: 1. 对于任意m作为输入,得到输出的结果,很难找到另一个输入m'  (m'不等于m),使得m'的Hash结果也为同样的输出

新手村 1万+

RAG 实战:LangChain + 向量数据库构建知识问答系统

从文档加载、分割、嵌入到检索增强生成,完整实现一个基于本地文档的知识问答系统。

kaixin110a的博客 189

【AI理论学习】深入理解扩散模型:Diffusion Models(DDPM)(理论篇)

继OpenAI在2021提出的文本转图像模型之后,越来越多的大公司卷入这个方向,例如谷歌相继推出了和。一些主流的文本转图像模型,例如,和采用了扩散模型()作为图像生成模型,这也引发了对扩散模型的研究热潮。与GAN相比,扩散模型训练更稳定,而且能够生成更多样的样本,OpenAI的论文也证明了

小哲的博客 5213

【零基础入门unity游戏开发——unity通用篇14】unity特性相关的知识(基于unity6开发介绍)

unity特性相关的知识(基于unity6开发介绍)

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 1204

添加USB wifi驱动到RK3568

在日常开发中我们经常需要用到wifi功能,一般来说soc厂家都会事先做好了几个厂家的wifi驱动在内核源码目录下,我们只需要按原理图配置对应的设备树即可。常用的wifi的接口有:USBSDIOPCIE下面来介绍这这种接口是如何使用wifi芯片。提示:以下是本篇文章正文内容,下面案例可供参考本小节介绍了一个配置一个USBwifi驱动的整个流程,并没有介绍到SDIO,下小节基于AP6256介绍如何使用。

qq_24093081的博客 2049

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: IDEA无法启动: The IDE cannot create the directory
下一篇: 02 - Redis源码结构介绍
急景凋年
博客等级 码龄14年 42粉丝 41原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值