Enumerations

The following enumerations are available globally.

  • KeychainError represents errors that can occur while interacting with the keychain.

    See more

    Declaration

    Swift

    public enum KeychainError : LocalizedError, Sendable
  • EncryptorError represents errors that can occur while encrypting/decrypting.

    See more

    Declaration

    Swift

    public enum EncryptorError : LocalizedError, Sendable
  • Defines the caching strategy for storage operations.

    The cache strategy determines how StorageDelegate manages 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:

    1. Is storage reliable and always available?

      • Yes → Consider NO_CACHE or CACHE
      • No → Use CACHE_ON_FAILURE
    2. Is read performance critical?

      • Yes → Use CACHE
      • No → Consider NO_CACHE or CACHE_ON_FAILURE
    3. Must data always be fresh?

      • Yes → Use NO_CACHE
      • No → Use CACHE or CACHE_ON_FAILURE

    Thread Safety

    All cache strategies are thread-safe through Swift actor isolation.

    See also

    StorageDelegate
    See more

    Declaration

    Swift

    public enum CacheStrategy