Right now, the way we save a page is by starting a one-off thread with a specific title to be saved. This will no longer be practical when we implement synchronized collections, and it's already no longer practical for users who refresh a large number of saved pages simultaneously.
The proposed solution is to create a Service that runs in the background, and checks for saved page titles that are "dirty" and need to be written to the filesystem. For example, under our current implementation of saved pages, the solution would be:
- When the user saves a page, add the title to the db (and nothing else).
- The Service does a periodic check of the db, and checks whether each title entry is present on disk.
- For every title that isn't present on disk, the Service queues it up to be fetched and written.
- (optional) When the user saves a page, or updates a collection in the future, we can kick the dog in the Service, and make it fetch the new saved page(s) as soon as possible.