Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add key/value store write buffer helper #361

Merged
merged 5 commits into from
Nov 21, 2023
Merged

Conversation

wazzamatazz
Copy link
Contributor

@wazzamatazz wazzamatazz commented Nov 14, 2023

Adds a new KeyValueStoreWriteBuffer class to DataCore.Adapter.Abstractions.

KeyValueStoreWriteBuffer allows IKeyValueStore implementations to put pending write and delete actions in an in-memory buffer that invokes a callback to flush the pending changes on a periodic basis, or if the number of pending changes or the overall byte size of the changes hit their respective limits.

The SQLite-based store has been modified to replace its own write buffer with KeyValueStoreWriteBuffer and the file system-based store can now use the same write buffer.

`KeyValueStoreWriteBuffer` is a new helper class that replicates (and extends) the write buffering in the SQLite key/value store so that the buffering can be used in any implementation that requires it.

In addition to periodic flushing of pending changes, `KeyValueStoreWriteBuffer` also allows automatic flushing to be configured when the number of pending changes exceeds a limit or the total byte size or the pending changes exceeds a limit.

The SQLite-based store has been rewritten to use `KeyValueStoreWriteBuffer` instead of its own implementation.
Instead of setting a `_useBackgroundFlush` field to specify if a write buffer is being used, adds a new `UseWriteBuffer` property that returns `true` if the `_writeBuffer` is not `null`.
@wazzamatazz wazzamatazz merged commit a90ea4a into develop/3.1.0 Nov 21, 2023
1 check passed
@wazzamatazz wazzamatazz deleted the kv-write-buffer branch November 21, 2023 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant