jamesmontemagno / monkey-cache

Easily cache any data structure for a specific amount of time in any .NET application.
MIT License
666 stars 105 forks source link

Bump LiteDB to latest version (5.0.19) to support AutoRebuild functionality in ConnectionString, Other Fixes #137

Closed alexanderdibenedetto closed 6 months ago

alexanderdibenedetto commented 6 months ago

Problem

A production .NET MAUI app I support uses MonkeyCache.LiteDB, and it has quite a few ENSURE and other exceptions as have been reported on the main LiteDB GitHub (https://github.com/mbdavid/LiteDB/releases). They were listed as fixed via the "completely redesigned" auto-rebuild functionality in 5.0.18 along with other bugs.

Typically, we could update LiteDB without needing it updated here, but to get this functionality, we need the ConnectionString MonkeyCache uses to opt-in to this AutoRebuild functionality. See here:

Added "AutoRebuild" option in Connection String In this version, the Rebuild command has been completely redesigned to be able to recover a full or partial database in case of data corruption. When detecting a structural error (known as the ENSURE exception) the data file will be modified to indicate that this file may be corrupt. When reopening the database, a rebuild process can be performed recovering as much data as possible. Use the "auto-rebuild=true" option in the connection string to activate this functionality. Possible errors found during the rebuild process will be stored in a new collection called "_rebuild_errors". A backup of the original file is created with the "-backup" suffix

Solution I'm proposing that you add a boolean such as

Barrel.AutoRebuildEnabled

that would have the effect of passing the auto-rebuild=true functionality to the LiteDB connection string for users of MonkeyCache that would like this functionality. Alternatively, if you think there are few people who wouldn't want it, opt MonkeyCache LiteDB users into this functionality for us.

I'm sure it goes without saying, but this proposal also includes bumping to the latest version of LiteDB available at the time this action is performed.

alexanderdibenedetto commented 6 months ago

@jamesmontemagno thank you for your quick response on this, I appreciate you!