Skip to content

2nd call to MemoryCache.Set() with the same key erases entry if cache is full#9933

Closed
pedrobsaila wants to merge 3 commits into
dotnet:mainfrom
pedrobsaila:runtime36039
Closed

2nd call to MemoryCache.Set() with the same key erases entry if cache is full#9933
pedrobsaila wants to merge 3 commits into
dotnet:mainfrom
pedrobsaila:runtime36039

Conversation

@pedrobsaila

@pedrobsaila pedrobsaila commented May 19, 2024

Copy link
Copy Markdown
Contributor

Summary

These changes document a strange behaviour (though understandable) in memory cache where existing and new entries get deleted when size limit is set and exceeded

Contributes to dotnet/runtime#36039

@pedrobsaila pedrobsaila requested a review from a team as a code owner May 19, 2024 13:23
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label May 19, 2024
@learn-build-service-prod

This comment was marked as outdated.

@learn-build-service-prod

Copy link
Copy Markdown

Learn Build status updates of commit 60f05af:

✅ Validation status: passed

File Status Preview URL Details
xml/Microsoft.Extensions.Caching.Memory/MemoryCacheOptions.xml ✅Succeeded View

For more details, please refer to the build report.

For any questions, please:

> [!CAUTION]
> There may be transient states while the cache is full but blocks are being released on a background thread. In this state, unexpected behavior might occur if the cache is being overutilized.
>
> When updating an existing item with another one that will make cache size go beyond the limit, the existing and new items will be removed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't know that this makes sense. Isn't "updating an existing item with another one" actually replacing an item? The wording sounds like "replace" not "update"

@adegeo

adegeo commented Jun 11, 2024

Copy link
Copy Markdown
Contributor

You can use <xref:Microsoft.Extensions.Caching.Memory.CacheExtensions.Set%2A> to link to an API in markdown

@learn-build-service-prod

Copy link
Copy Markdown

Learn Build status updates of commit 27a2065:

✅ Validation status: passed

File Status Preview URL Details
xml/Microsoft.Extensions.Caching.Memory/MemoryCacheOptions.xml ✅Succeeded View

For more details, please refer to the build report.

For any questions, please:

@gewarren

Copy link
Copy Markdown
Collaborator

I believe we can close this given that the underlying behavior was fixed in dotnet/runtime#103931.

@gewarren gewarren closed this Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Extensions-Caching community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants