-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for existing key and add FASTER size tracking metrics (#367)
* Create ScopedRawKeyValueStore.cs New wrapper class for a scoped `IRawKeyValueStore`. * Update IKeyValueStore.cs Add a new `ExistsAsync` method for detecting if a key exists without reading its value. * Implement ExistsAsync * Update ScopedKeyValueStore.cs Implement ExistsAsync and make class internal * Update KeyValueStoreExtensions.cs `BulkCopyToAsync`/`BulkCopyFromAsync` now include an `overwrite` parameter that controls if existing keys in the destination store should be overwritten. `CreateScopedStore` has been updated to return a `ScopedRawKeyValueStore` if the store to be wrapped implements `IRawKeyValueStore`. * Update API declarations * Implement ExistsAsync/add size tracking metrics Implements `ExistsAsync` in the FASTER key/value store. Adds functionality (based on the FASTER GitHub samples) for tracking the memory footprint of a FASTER key/value store. Adds metrics to `FasterKeyValueStore` for reporting memory usage. * Update unit tests Adds tests for `ExistsAsync` and disposes stores using `IAsyncDisposable.DisposeAsync` in preference to `IDisposable.Dispose` if defined on a store implementation. * Size tracking optimisations
- Loading branch information
1 parent
5fd07c0
commit 44d873b
Showing
22 changed files
with
881 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/DataCore.Adapter.Abstractions/Services/ScopedRawKeyValueStore.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace DataCore.Adapter.Services { | ||
|
||
/// <summary> | ||
/// <see cref="IRawKeyValueStore"/> that wraps an existing <see cref="IRawKeyValueStore"/> and | ||
/// automatically modifies keys passed in or out of the store using a scoped prefix. | ||
/// </summary> | ||
internal class ScopedRawKeyValueStore : ScopedKeyValueStore, IRawKeyValueStore { | ||
|
||
/// <summary> | ||
/// The inner <see cref="IRawKeyValueStore"/>. | ||
/// </summary> | ||
internal new IRawKeyValueStore Inner => (IRawKeyValueStore) base.Inner; | ||
|
||
|
||
/// <summary> | ||
/// Creates a new <see cref="ScopedRawKeyValueStore"/> object. | ||
/// </summary> | ||
/// <param name="prefix"> | ||
/// The key prefix for the store. | ||
/// </param> | ||
/// <param name="inner"> | ||
/// The inner <see cref="IRawKeyValueStore"/> to wrap. | ||
/// </param> | ||
public ScopedRawKeyValueStore(KVKey prefix, IRawKeyValueStore inner) | ||
: base(prefix, inner) { } | ||
|
||
|
||
/// <inheritdoc/> | ||
public ValueTask<byte[]?> ReadRawAsync(KVKey key) { | ||
var k = KeyValueStore.AddPrefix(Prefix, key); | ||
return Inner.ReadRawAsync(k); | ||
} | ||
|
||
|
||
/// <inheritdoc/> | ||
public ValueTask WriteRawAsync(KVKey key, byte[] value) { | ||
var k = KeyValueStore.AddPrefix(Prefix, key); | ||
return Inner.WriteRawAsync(k, value); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.