Enumerations
The following enumerations are available globally.
-
See moreKeychainErrorrepresents errors that can occur while interacting with the keychain.Declaration
Swift
public enum KeychainError : LocalizedError, Sendable -
See moreEncryptorErrorrepresents errors that can occur while encrypting/decrypting.Declaration
Swift
public enum EncryptorError : LocalizedError, Sendable -
Defines the caching strategy for storage operations.
The cache strategy determines how
StorageDelegatemanages its in-memory cache in relation to the underlying storage. Each strategy offers different trade-offs between performance, consistency, and resilience.Available Strategies
CACHE
Priority: Performance
Items are cached in memory when saved. Reads are served from cache when available, providing the fastest possible access.
Use when: Performance is critical and you can tolerate cache-storage inconsistencies on save failures.
NO_CACHE
Priority: Consistency
No caching layer is used. All operations go directly to the underlying storage, ensuring you always have the most recent data from the source of truth.
Use when: You always need fresh data or memory usage is a concern.
CACHE_ON_FAILURE
Priority: Resilience
Cache serves as a fallback mechanism when storage operations fail. On successful operations, fresh data is fetched from storage and cached. Cache is used only when storage is unavailable.
Use when: You need resilience against intermittent failures and can tolerate stale data.
Choosing a Strategy
Use this decision tree:
Is storage reliable and always available?
- Yes → Consider
NO_CACHEorCACHE - No → Use
CACHE_ON_FAILURE
- Yes → Consider
Is read performance critical?
- Yes → Use
CACHE - No → Consider
NO_CACHEorCACHE_ON_FAILURE
- Yes → Use
Must data always be fresh?
- Yes → Use
NO_CACHE - No → Use
CACHEorCACHE_ON_FAILURE
- Yes → Use
Thread Safety
All cache strategies are thread-safe through Swift actor isolation.
See moreSee also
StorageDelegateDeclaration
Swift
public enum CacheStrategy
View on GitHub
Enumerations Reference