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

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

pedrobsaila
Copy link
Contributor

@pedrobsaila pedrobsaila commented May 19, 2024

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
Copy link

Learn Build status updates of commit ed0bede:

⚠️ Validation status: warnings

File Status Preview URL Details
xml/Microsoft.Extensions.Caching.Memory/MemoryCacheOptions.xml ⚠️Warning View Details

xml/Microsoft.Extensions.Caching.Memory/MemoryCacheOptions.xml

  • Line 0, Column 0: [Warning: disallowed-html-tag - See documentation] HTML tag 'see' isn't allowed. Replace it with approved Markdown or escape the brackets if the content is a placeholder.

For more details, please refer to the build report.

Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them.

For any questions, please:

Copy link

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
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
Copy link
Contributor

adegeo commented Jun 11, 2024

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

Copy link

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:

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.

None yet

2 participants