swift-actor-persistence
Thread-safe data persistence in Swift using actors — in-memory cache with file-backed storage, eliminating data races by design.
Target: Design & content creation. Automatically collected · unverified.
Excerpt from the author’s documentation
Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.
Read the original English text
Topics in the source
- Swift Actors for Thread-Safe Persistence
- When to Activate
- Core Pattern
- Actor-Based Repository
- Usage
- Combining with @Observable ViewModel
- Key Design Decisions
- Best Practices
Patterns for building thread-safe data persistence layers using Swift actors. Combines in-memory caching with file-backed storage, leveraging the actor model to eliminate data races at compile time. Building a data persistence layer in Swift 5.9+ (iOS 17+, macOS 14+) Need thread-safe access to shared mutable state Want to eliminate manual synchronization (locks, DispatchQueues) Building offline-first apps with local storage The actor model guarantees serialized access — no data races, enforced by the compiler. All calls are automatically async due to actor isolation: | Decision | Rationale | |----------|-----------| | Actor (not class + lock) | Compiler-enforced thread safety, no manual synchronization | | In-memory cache + file persistence | Fast reads from cache, durable writes to disk | | Synchronous init loading | Avoids async initialization complexity | | Dictionary keyed by ID | O(1) lookups by identifier | | Generic over Codable & Identifiable | Reusable across any model type | | Atomic file writes (.atomic) | Prevents partial writes on crash | Use Sendable types for all data crossing actor boundaries Keep the actor's public API minimal — only expose domain operations, not p
This is an excerpt. Refer to the complete source and its current requirements.
- Source repository
- affaan-m/ECC
- Source file
- .kiro/skills/swift-actor-persistence/SKILL.md
- Fixed revision
- d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Sources and evidence
This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.
Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T14:01:48.694Z.
Categories are inferred from names, descriptions and paths. They do not establish compatibility.
License and attribution
MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.
Original license ↗Synchronization, copying and user-reported success do not mark a resource as runtime-tested.
Limitations and notes
- Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.