intelligentplant / AppStoreConnect.Adapters

Allows Intelligent Plant App Store Connect to query 3rd party systems
https://appstore.intelligentplant.com
MIT License
0 stars 0 forks source link

Add background flush to SQLite key/value store #360

Closed wazzamatazz closed 8 months ago

wazzamatazz commented 8 months ago

This PR adds a property to SqliteKeyValueStoreOptions for defining a background flush interval.

When the interval is greater than TimeSpan.Zero, write and delete operations are no longer immediately performed. Instead, they are added to a dictionary (indexed by key). The value for the entry is the byte array for the updated value, or null if the key should be deleted.

When the flush interval is reached, a background task performs all of the pending changes and clears the pending operations dictionary. A flush can also be explicitly triggered using the new FlushAsync method on the SqliteKeyValueStore class.

The default behaviour is to write/delete from the database immediately, so the background flush capability is opt-in.