Skip to content

fix(asynccache): pass cached values to delete handlers - #269

Merged
PureWhiteWu merged 2 commits into
bytedance:mainfrom
Shubham-Padkonde:bugfix/asynccache-delete-handler
Sep 18, 2026
Merged

PureWhiteWu merged 2 commits into
bytedance:mainfrom
Shubham-Padkonde:bugfix/asynccache-delete-handler

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor

DeleteHandler currently receives the cache's private *entry wrapper. A handler expecting the stored value gets the wrong type, both when an entry expires and when DeleteIf removes it.

Load the cached value before dispatching either asynchronous callback, and document the argument. Add six regression cases for strings, pointers, and nil values across both deletion paths. The tests also check that non-matching/touched entries remain and the first expiration pass does not delete an entry.

Fixes #248.

Validation:

  • All six regression cases fail before the change and pass afterward.
  • Full repository go test -v -race -covermode=atomic ./... passes with Go 1.15.15, matching the CI Go series.
  • go vet -stdmethods=false ./... and repository-wide gofmt -s checks pass with Go 1.15.15.
  • Focused regression race checks also pass with Go 1.26.3.
  • Golangci-lint 2.10.1 reports no findings in changed code (--new-from-rev=HEAD). Its full-repository defaults report 52 findings on unchanged code; these are not included in this callback fix.
  • git diff --check passes.

Assisted by Codex/GPT-6 for investigation, coding, and validation.

Signed-off-by: Shubham Padkonde <shubhampadkonde12@gmail.com>
PureWhiteWu
PureWhiteWu previously approved these changes Sep 18, 2026

@PureWhiteWu PureWhiteWu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, thanks very much for the fix!

@PureWhiteWu

Copy link
Copy Markdown
Collaborator

Please change your target branch to main

@Shubham-Padkonde
Shubham-Padkonde changed the base branch from develop to main September 18, 2026 04:22
@Shubham-Padkonde
Shubham-Padkonde dismissed PureWhiteWu’s stale review September 18, 2026 04:22

The base branch was changed.

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor Author

@PureWhiteWu Retargeted to main and updated the branch with the latest main. The diff is still just the two asynccache files. The base change auto-dismissed your earlier approval, so could you please re-approve? The required build check hasn't started yet, so if it needs maintainer approval to run, could you approve that too? Thanks!

@PureWhiteWu
PureWhiteWu merged commit c1b3d74 into bytedance:main Sep 18, 2026
2 checks passed
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.

cache中的DeleteHandler参数问题,看起来像是实现错了

2 participants