-
Notifications
You must be signed in to change notification settings - Fork 1.1k
The KEYS command needs to be keyless #3341
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
base: main
Are you sure you want to change the base?
Conversation
bb9b5e8
to
d49dd31
Compare
Hi @tishun, could you please take a look at this PR when you have a moment? |
Hey @Dltmd202 , unfortunately we can't change the existing API without deprecating it first. So can you please add new methods with the new signature, and leave out the old ones with a @deprecated notice in the JAvaDoc and a @deprecated annotation of each API method? |
Hi @tishun, Got it — I’ll go ahead and add the new methods with the updated signature, and mark the existing ones as deprecated using the @deprecated annotation and JavaDoc. Thanks for the clarification! |
Hi, @tishun While working on a contribution, I ran into a problem with the keys methods. List<K> keys(String pattern); // new API
@Deprecated
List<K> keys(K pattern); // legacy API When K is String, both look like keys(String) to the compiler, so it can’t decide which one to call. @Test
void testComposedCodec() {
RedisCodec<String, Object> composed =
RedisCodec.of(StringCodec.ASCII, new SerializedObjectCodec());
RedisCommands<String, Object> connection = client.connect(composed).sync();
connection.set(key, new Person());
// Ambiguous when K = String
List<String> keys = connection.keys(key);
assertThat(keys).hasSize(1);
assertThat(connection.get(key)).isInstanceOf(Person.class);
connection.getStatefulConnection().close();
} This makes it tricky to keep both signatures during a deprecation phase. Let me know which direction you’d like to take, and I can adjust the PR accordingly. |
Ah, unfortunate, indeed. IMHO an exception to the rule can be made here, since we are considering to release 7.x, which is a major release:
Argumentation:
If we were to follow a different route then we would either have to change the API a second time (when we finally remove the deprecated API); which - by the same rule - would require first to deprecate the newly introduced method and then to remove it in a separate release; Eventually having to keep this mess for another major release. @ggivo , @a-TODO-rov , @uglide - what do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we moving this file from the templates package ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the advantages of adding new GlobalPatternArgument against using StringArgument ?
The KEYS command needs to be keyless
The request policy of the KEYS command specifies that the command should have a
request_policy:all_shards
.As such the parameters of the command should be considered keyless and the routing should be done to all nodes. Right now we have a K key parameter, which would assume that we need it for routing.
The underlying logic does route (in multi-shard environments) the command to all shards, but it still treats the parameter as a key for the purposes of serialization.
This is somewhat invalid if a user configures their own codec, because it requires that they treat keys and patterns with the same abstraction.
Closes #3311
Make sure that:
mvn formatter:format
target. Don’t submit any formatting related changes.