Skip to content

refactor(cache): extract shared redis base and fetch-through helper#84

Merged
appleboy merged 1 commit intomainfrom
redis2
Mar 8, 2026
Merged

refactor(cache): extract shared redis base and fetch-through helper#84
appleboy merged 1 commit intomainfrom
redis2

Conversation

@appleboy
Copy link
Copy Markdown
Member

@appleboy appleboy commented Mar 8, 2026

Summary

  • Extract duplicated Set, MSet, Delete, Close, and Health methods from RueidisCache and RueidisAsideCache into an embedded redisBase[T] struct, eliminating ~60 lines of copy-paste
  • Extract identical cache-aside logic (Get → fetch → Set) into a shared fetchThrough[T] helper, used by both MemoryCache and RueidisCache
  • Net reduction of 56 lines with no behavior change

Test plan

  • All 20 existing cache tests pass (go test ./internal/cache/)
  • Full project builds cleanly (go build ./...)
  • Verify Redis-backed caches work in integration environment

🤖 Generated with Claude Code

- Extract duplicated Set, MSet, Delete, Close, and Health methods into embedded redisBase struct
- Extract cache-aside pattern into shared fetchThrough helper used by MemoryCache and RueidisCache
- Simplify RueidisCache and RueidisAsideCache by embedding redisBase

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 8, 2026 04:01
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 8, 2026

Codecov Report

❌ Patch coverage is 13.33333% with 65 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/cache/redis_base.go 0.00% 43 Missing ⚠️
internal/cache/rueidis_aside.go 0.00% 16 Missing ⚠️
internal/cache/rueidis.go 0.00% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@appleboy appleboy merged commit fa9a51e into main Mar 8, 2026
16 of 17 checks passed
@appleboy appleboy deleted the redis2 branch March 8, 2026 04:11
@appleboy appleboy review requested due to automatic review settings March 23, 2026 19:51
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.

1 participant