Individual skill

swift-actor-persistence

Swift 中使用 actor 实现的线程安全数据持久化 —— 结合内存缓存与文件存储,从设计上消除数据竞争。

skills/swift-actor-persistence/SKILL.md

Read pinned source

Source commit dfbf9467b90dfd29bffa842c4e0a6977112900e2

What was checked

Matches the observed repository HEAD
Yes
Scanner rules are current
No
Repository scan complete
No
Skill scan complete
No
Observed behavior
Not checked yet
Last checked
Nov 3, 2026

These are observations at the recorded commit, not a guarantee of safety. Review the source before running it.

Install this skill

Choose an agent in your Stack or copy a command below. Commands fetch the pinned commit and copy only this skill directory. Existing destinations are refused. Copying a command does not install anything.

An install command is unavailable: current rules, complete repository and skill scans, an eligible behavior level and a permitted license are required.

Repository context

Repository stars (not skill ratings)
2,024
Repository last updated
Mar 5, 2026
License
MIT

Observed agent integration: No specific integration evidence. Standard SKILL.md installation does not imply verified compatibility.

Files and excerpt

File metadata and permitted, redacted excerpts come from the recorded scan. Source links are pinned to that commit.

Browse files
Read excerpt

# 使用 Swift Actors 实现线程安全持久化 (Swift Actors for Thread-Safe Persistence)

使用 Swift actor 构建线程安全数据持久化层的模式。该模式结合了内存缓存(In-memory caching)与基于文件的存储,利用 actor 模型(Actor model)在编译时消除数据竞争(Data races)。

## 何时启用

- 在 Swift 5.5+ 中构建数据持久化层
- 需要对共享可变状态(Shared mutable state)进行线程安全访问
- 希望消除手动同步操作(如 locks、DispatchQueues)
- 构建具有本地存储的离线优先(Offline-first)应用

## 核心模式 (Core Pattern)

### 基于 Actor 的仓库模式 (Actor-Based Repository)