title, type, tags, sources, last_updated
| title |
type |
tags |
sources |
last_updated |
| File Watcher (Auto-Reindex) |
concept |
| automation |
| file-system |
| indexing |
| realtime |
|
|
2026-04-22 |
Aliases
- File Watcher
- 文件监视器
- 文件监听
- Auto-Reindex
- 自动重建索引
Definition
文件监视器是一种实时监控指定目录文件变化的机制,当文件被创建、修改或删除时,自动触发相应的索引更新操作。在语义搜索场景中,这意味着记忆文件的变更会即时反映到向量索引中,保持索引与源文档的同步,无需手动重新运行索引命令。
How It Works
Implementation Patterns
| 方式 |
工具 |
说明 |
| 轮询 |
watchdog (Python) |
跨平台,跨语言,通用 |
| 系统事件 |
inotify (Linux) / FSEvents (macOS) / ReadDirectoryChangesW (Windows) |
高效,仅 Linux/macOS/Windows 原生 |
| cron 批处理 |
*/5 * * * * |
简单,不实时,适合低频场景 |
| Webhook |
Git post-commit hook |
适合 Git 管理的文档 |
Use Case in memsearch
memsearch 的 memsearch watch 命令使用文件监视器自动追踪记忆目录变化:
Benefits
- 实时同步:索引始终反映最新文档状态
- 零手动操作:无需人工干预,忘记索引更新也不怕
- 节省成本:基于 Content Hashing 的增量机制,仅处理实际变化部分
Connections