Skip to content

SQLCipher v2.0.0

Choose a tag to compare

@mark-onyschuk mark-onyschuk released this 15 Feb 13:32
· 60 commits to main since this release

SQLCipher v2.0.0

Welcome to SQLCipher v2.0. SQLCipher v2.0 builds overtop of a standard C SQLCipher library, offering a Swift language abstraction for database connections, queries, and results. A higher level abstraction provides support for state containers akin to Redux, but with additional support for SQL storage. Here are some of its key classes and types:

Key Class: SQLCipherStore

SQLCipherStore is the central class in the framework, designed to manage application state in a Redux-like manner while integrating with an encrypted SQLite database (via SQLCipher). It provides a predictable, centralized mechanism for state management, supports undo/redo functionality, and ensures state persistence by synchronizing changes with the database.

Key Features

  • Redux-Like Architecture: Centralized state management with support for dispatching actions and middleware-like extensibility.
  • Undo/Redo Support: Tracks state changes and allows reverting or reapplying them.
  • State Persistence: Synchronizes state with an encrypted SQLite database, ensuring data consistency and recovery.
  • Thread Safety: Manages concurrency internally, ensuring thread-safe state updates and database interactions.

Example Use Cases

  • Managing application state in a predictable, centralized way.
  • Persisting state changes to an encrypted database for secure storage.
  • Implementing undo/redo functionality in applications like task managers, editors, or data entry systems.
  • Supporting long-running operations with progress tracking and cancelation.

SQLCipherStore is the backbone of the framework, combining the principles of Redux with the power of SQLCipher to deliver a robust, secure, and extensible state management solution.

Key Protocol: SQLAction

SQLAction defines a single, state-modifying action within a SQLCipherStore. It encapsulates the logic for updating the application state and optionally interacting with the database. This protocol is the foundation for Redux-style state management in the framework, allowing developers to define discrete, reusable actions that describe "what happened" in the application.

Key Features

  • Encapsulates state-modifying logic into discrete, reusable units.
  • Supports undo/redo functionality by specifying the UpdateType.
  • Provides access to the database for performing SQL operations during state updates.

Example Use Case

A SQLAction might represent an operation like adding a new task, marking a task as completed, or deleting a record. Each action encapsulates the logic for modifying the state and interacting with the database, making the code modular and testable.

Key Protocol: SQLCompositeAction

SQLCompositeAction defines a long-running, asynchronous operation that modifies the state in a SQLCipherStore. It is designed for complex workflows that involve multiple steps, progress tracking, and potential cancelation. This protocol extends the capabilities of SQLAction by supporting asynchronous execution and real-time progress updates.

Key Features

  • Supports asynchronous, multi-step operations.
  • Provides real-time progress updates via SQLActionProgress.
  • Allows cancelation of long-running operations.
  • Integrates seamlessly with SQLCipherStore for state updates and database interactions.

Example Use Case

A SQLCompositeAction might represent a workflow like importing a large dataset, performing a batch update, or synchronizing data with a remote server. The action can report progress to the user and handle cancelation gracefully.