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

feat:add redis ExistsMany method #3769

Merged
merged 1 commit into from
Dec 16, 2023

Conversation

codeErrorSleep
Copy link
Contributor

The current Exists function in go-zero's Redis only supports a single key, whereas go-redis's Exists can query multiple keys.
However, directly altering go-zero's Redis implementation would lead to incompatibility between different versions of the method and would affect the implementation of the Store interface in core/stores/kv/store.go.
To ensure compatibility between versions, a new method named ExistsMany should be added as a transitional solution. A unified upgrade can be planned for a later major version release.
close #3765

// go-zero
// core/stores/redis.go:458
v, err := conn.Exists(ctx, key).Result()

// go-redis
Exists(ctx context.Context, keys ...string) *IntCmd

@kevwan
Copy link
Contributor

kevwan commented Dec 15, 2023

I think you can just modify Exists method.

@kevwan kevwan force-pushed the feature/redis-exists-many branch from cac80fe to fec125a Compare December 16, 2023 06:38
Copy link
Contributor

@kevwan kevwan left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link

codecov bot commented Dec 16, 2023

Codecov Report

Merging #3769 (fec125a) into master (8c2f4c1) will decrease coverage by 0.02%.
The diff coverage is 80.00%.

Additional details and impacted files
Files Coverage Δ
core/stores/redis/redis.go 98.30% <80.00%> (-0.17%) ⬇️

@kevwan kevwan merged commit 431f9af into zeromicro:master Dec 16, 2023
5 of 6 checks passed
@codeErrorSleep codeErrorSleep deleted the feature/redis-exists-many branch December 17, 2023 06:54
WqyJh pushed a commit to WqyJh/go-zero that referenced this pull request Dec 21, 2023
dongmeng199 pushed a commit to dongmeng199/go-zero that referenced this pull request Dec 24, 2023
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.

Why redis.Exists() accept only one key in go-zero?
2 participants