Skip to content

Add api to remove a single entry from FluidCache#26065

Merged
shubhi1092 merged 2 commits into
mainfrom
shuagarwal/add-removeEntry-fluidCache
Dec 18, 2025
Merged

Add api to remove a single entry from FluidCache#26065
shubhi1092 merged 2 commits into
mainfrom
shuagarwal/add-removeEntry-fluidCache

Conversation

@shubhi1092
Copy link
Copy Markdown
Contributor

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.

Copilot AI review requested due to automatic review settings December 17, 2025 00:05
@shubhi1092 shubhi1092 changed the title Add api to remove a single entry from fluidCache Add api to remove a single entry from FluidCache Dec 17, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 removeEntry optional method to IPersistedCache interface for granular cache entry removal
  • Implemented removeEntry in FluidCache class 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

Comment on lines +187 to +216
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
});
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test coverage for the new removeEntry method is incomplete. Consider adding test cases for:

  1. Attempting to remove a non-existent entry (should not throw)
  2. Behavior when the database has been upgraded by another client (similar to line 250)
  3. 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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot update this pull request by applying changes based on this feedback

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 17, 2025

@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.

@shubhi1092 shubhi1092 requested a review from a team as a code owner December 17, 2025 00:30
@github-actions
Copy link
Copy Markdown
Contributor

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> fluid-framework-docs-site@0.0.0 ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> fluid-framework-docs-site@0.0.0 serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> fluid-framework-docs-site@0.0.0 check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

Stats:
  245432 links
    1786 destination URLs
    2025 URLs ignored
       0 warnings
       0 errors


@shubhi1092 shubhi1092 merged commit e5586b8 into main Dec 18, 2025
35 checks passed
@shubhi1092 shubhi1092 deleted the shuagarwal/add-removeEntry-fluidCache branch December 18, 2025 18:14
anthony-murphy-agent pushed a commit to anthony-murphy-agent/FluidFramework that referenced this pull request Jan 14, 2026
## 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>
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.

4 participants