<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Change Streams on PlumePHP</title><link>https://plumephp.com/tags/change-streams/</link><description>Recent content in Change Streams on PlumePHP</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Fri, 14 Aug 2026 12:08:00 +0800</lastBuildDate><atom:link href="https://plumephp.com/tags/change-streams/index.xml" rel="self" type="application/rss+xml"/><item><title>08. MongoDB Change Streams 实时同步</title><link>https://plumephp.com/mongodb-change-streams/</link><pubDate>Fri, 14 Aug 2026 12:08:00 +0800</pubDate><guid>https://plumephp.com/mongodb-change-streams/</guid><description>&lt;p&gt;Change Streams 是 MongoDB 3.6 引入的功能，允许应用实时监听集合（或整个数据库）的变更事件。它是构建事件驱动架构、数据同步、缓存失效等场景的核心工具。&lt;/p&gt;
&lt;h2 id="1-基本原理"&gt;1. 基本原理&lt;/h2&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;应用层 MongoDB
 │ │
 ├─── watch(&amp;#34;db.orders&amp;#34;) ──────────→┤
 │ (建立长连接) │
 │ ←── 变更事件推送 ─────────────┤
 │ │
 │ 事件类型: insert / update / delete
 │ 包含: 完整文档/变更差异 + Namespace + clusterTime
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Change Streams 基于 oplog，因此要求 MongoDB 以复制集或分片集群方式运行。&lt;/p&gt;</description></item></channel></rss>