Skip to content

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

Closed
pedrobsaila wants to merge 2 commits into
dotnet:mainfrom
pedrobsaila:36039
Closed

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

Conversation

@pedrobsaila

Copy link
Copy Markdown
Contributor

Fixes #36039


priorEntry?.InvokeEvictionCallbacks();
}
else if (_options.HasSizeLimit && priorEntry != null && priorEntry.Size >= entry.Size)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it be possible to avoid a separate case here by passing priorEntry to UpdateCacheSizeExceedsCapacity? @Tratcher mentioned in the issue that he thought the cause here was that that method didn't consider the size of the evicted item.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree, for this case we should run the same logic we run for not exceeding capacity.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ericstj

ericstj commented Jun 24, 2024

Copy link
Copy Markdown
Member

@dotnet/area-extensions-caching @mgravell or @sebastienros -- can one you have a look?

@jozkee jozkee closed this Jun 28, 2024
@pedrobsaila pedrobsaila deleted the 36039 branch June 29, 2024 12:31
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

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

3 participants