Add api to remove a single entry from FluidCache#26065
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new optional method removeEntry to the IPersistedCache interface, allowing removal of a single cache entry instead of all entries for a document. The change is backward compatible since the method is optional, but breaks forward compatibility as documented in the type validation changes.
Key Changes
- Added
removeEntryoptional method toIPersistedCacheinterface for granular cache entry removal - Implemented
removeEntryinFluidCacheclass with appropriate error handling and telemetry - Added comprehensive test coverage for the new functionality
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/common/driver-definitions/src/cacheDefinitions.ts | Added optional removeEntry method to IPersistedCache interface with documentation |
| packages/drivers/driver-web-cache/src/FluidCache.ts | Implemented removeEntry method with error handling pattern consistent with removeEntries |
| packages/drivers/driver-web-cache/src/fluidCacheTelemetry.ts | Added new error event FluidCacheDeleteSingleEntryError for telemetry tracking |
| packages/drivers/driver-web-cache/src/test/FluidCache.test.ts | Added test case verifying selective entry removal without affecting other entries |
| packages/drivers/driver-web-cache/package.json | Updated type validation configuration to document forward compatibility break |
| packages/drivers/driver-web-cache/src/test/types/validateDriverWebCachePrevious.generated.ts | Added ts-expect-error directive for expected compatibility break |
| it("removes a specific entry without affecting other entries for the same document", async () => { | ||
| const fluidCache = getFluidCache(); | ||
|
|
||
| const docId1Entry1 = getMockCacheEntry("docId1Entry1", { | ||
| docId: "docId1", | ||
| }); | ||
| const docId1Entry2 = getMockCacheEntry("docId1Entry2", { | ||
| docId: "docId1", | ||
| }); | ||
| const docId2Entry1 = getMockCacheEntry("docId2Entry1", { | ||
| docId: "docId2", | ||
| }); | ||
|
|
||
| await fluidCache.put(docId1Entry1, { data: "entry1" }); | ||
| await fluidCache.put(docId1Entry2, { data: "entry2" }); | ||
| await fluidCache.put(docId2Entry1, { data: "entry3" }); | ||
|
|
||
| // Verify all entries exist | ||
| expect(await fluidCache.get(docId1Entry1)).toEqual({ data: "entry1" }); | ||
| expect(await fluidCache.get(docId1Entry2)).toEqual({ data: "entry2" }); | ||
| expect(await fluidCache.get(docId2Entry1)).toEqual({ data: "entry3" }); | ||
|
|
||
| // Remove only one specific entry from docId1 | ||
| await fluidCache.removeEntry(docId1Entry1); | ||
|
|
||
| // Verify only the specified entry was removed | ||
| expect(await fluidCache.get(docId1Entry1)).toBeUndefined(); | ||
| expect(await fluidCache.get(docId1Entry2)).toEqual({ data: "entry2" }); // Still exists | ||
| expect(await fluidCache.get(docId2Entry1)).toEqual({ data: "entry3" }); // Still exists | ||
| }); |
There was a problem hiding this comment.
The test coverage for the new removeEntry method is incomplete. Consider adding test cases for:
- Attempting to remove a non-existent entry (should not throw)
- Behavior when the database has been upgraded by another client (similar to line 250)
- Behavior when an older client is blocking the database (similar to line 264)
These scenarios are tested for other cache operations and would ensure consistent behavior across all API methods.
There was a problem hiding this comment.
@copilot update this pull request by applying changes based on this feedback
|
@shubhi1092 I've opened a new pull request, #26066, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
🔗 No broken links found! ✅ Your attention to detail is admirable. linkcheck output |
## Description Added api to remove a single entry from fluidCache ## Breaking Changes Added an optional method for deleting a single entry from fluid cache - removeEntry. It is not forward compatible, but it is still backwards compatible because it is optional. --------- Co-authored-by: Shubhangi Agarwal <shuagarwal@microsoft.com>
Description
Added api to remove a single entry from fluidCache
Breaking Changes
Added an optional method for deleting a single entry from fluid cache - removeEntry.
It is not forward compatible, but it is still backwards compatible because it is optional.