Skip to content

Migrate core data persistence from in-memory to SQLite with GRDB.swift #128

@milanvarady

Description

@milanvarady

Current Situation

Currently, the app fetches all 10,000+ cask info models from the Homebrew API on launch and stores them in an in-memory array. This approach has two significant drawbacks:

  1. Slow Initial Load Time: Fetching, parsing, and compiling this large dataset at runtime causes a noticeable delay before the app is usable.
  2. Poor Search Performance: Searching the large in-memory array using the current fuzzy-search library is inefficient and provides suboptimal search relevance.

Proposed Solution

This plan is to refactor the core data layer to use a persistent, local SQLite database, managed by GRDB.swift.

  • Persistent Storage: On the first launch, the app will fetch all cask data from the API once and populate a local SQLite database file.
  • Fast Launches: On all subsequent launches, the app will read data near-instantly from the local database. The CaskInfo models will no longer be held in memory.
  • Background Refresh: A background task will be implemented to periodically refresh the database from the Homebrew API, ensuring the data stays current without blocking the user.
  • High-Performance Search: We will replace the current search implementation with SQLite's FTS5 (Full-Text Search) extension, which is fully supported by GRDB.

Expected Outcomes

  • Improved load time
  • Fast and relevant search results
  • Reduced memory consumption

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Status

Planned

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions