Skip to content

Evict corrupt distributed cache entries - #50

Merged
mheidari988 merged 1 commit into
mainfrom
feature/find-issues-to-fix-or-develop
Jun 3, 2026
Merged

Evict corrupt distributed cache entries#50
mheidari988 merged 1 commit into
mainfrom
feature/find-issues-to-fix-or-develop

Conversation

@mheidari988

Copy link
Copy Markdown
Contributor

Motivation

  • Prevent repeated cache misses and wasted work when a distributed cache entry contains a corrupt or incompatible payload by evicting the bad entry on read failures.

Description

  • On Get and GetAsync the adapter now evicts the distributed cache entry when deserialization fails and returns null instead of repeatedly returning the same corrupt payload.
  • Added RemoveInvalidEntry and RemoveInvalidEntryAsync helpers that remove the key and log a warning if cleanup fails.
  • Added two tests (Get_removes_corrupt_payload and GetAsync_removes_corrupt_payload) that insert an invalid payload into a MemoryDistributedCache and assert the adapter removes it on access, and added an overload to CreateAdapter to inject a shared IDistributedCache test double.

Testing

  • Ran code checks with git diff --check which reported no issues.
  • Attempted dotnet build CleanArchitecture.Extensions.sln --no-restore but the dotnet CLI is unavailable in this environment so the build could not be executed here.
  • Unit tests were not run per repository instruction.

Codex Task

@mheidari988
mheidari988 marked this pull request as ready for review June 3, 2026 13:18
@mheidari988
mheidari988 merged commit 977fba0 into main Jun 3, 2026
1 check passed
@mheidari988
mheidari988 deleted the feature/find-issues-to-fix-or-develop branch June 3, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant