-
Notifications
You must be signed in to change notification settings - Fork 995
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
Hash field is not a key #3124
Comments
Greetings @Xxdnx , What is your logic of treating the field name as a value?
In my perspective a key is used to identify data. Since there are two types of coding/decoding (one for key and one for value) the |
@tishun Thank you very much for your reply. As you mentioned above, the "Field" in Hash is the key of the sub-data, and I agree with this statement. However, I still think it is more appropriate to use the field of the hash as the value.
The following is the code for the hset method of |
Hey again,
Strictly speaking - yes. As I mentioned the model of Codec <Key, Value> is not perfect, because it does not define if fields are to be encoded as key or value and it is a matter of interpretation. As I mentioned - currently - the assumption is that the
It is quite unfortunate that there are differences between Jedis and Lettuce. However both drivers have a complex history and were maintained by different people, so there are inconsistencies between them. The bigger issue here is that of compatibility and consistency. They make any change very unlikely. ConsistencyCurrently all hash field commands consider the CompatibilityAdditionally any change right now would break existing users (as they already rely on the existing model). So any change would be a breaking change and as such I cannot accommodate it unless the community overwhelmingly agrees it needs to be done. Suggested solutionI think that your use case is more of an edge case. As such it would be prudent to just override the way the command is built and build it yourself. You could wrap the class you are using, e.g. @Override
public Mono<Boolean> hset(K key, K field, V value) {
return createMono(() ->
notNullKey(key);
LettuceAssert.notNull(field, "Field " + MUST_NOT_BE_NULL);
CommandArgs<K, V> args = new CommandArgs<>(codec).addKey(key).addValue(field).addValue(value);
return createCommand(HSET, new BooleanOutput<>(codec), args);
);
} Thus overriding the default way the driver works for all |
Overriding the default way the driver works for all HSET calls is feasible. However, for our business scenarios, making the modifications and rolling them out would take too much time. I'll think about other solutions. Thank you for your reply. |
If you need more help or have some comments please do not hesitate to reopen. |
Bug Report
Current Behavior
There is a business scenario where a fixed prefix needs to be added to Redis keys for specific requests. In the current implementation, when using Java Agent to rewrite the io.lettuce.core.protocol.CommandArgs#addKey(K key) method for adding a fixed prefix to Redis keys, there is an issue with Hash commands, as they wrongly consider the field as a key.
Input Code
Expected behavior/code
The encoding method logic of io.lettuce.core.protocol.CommandArgs$KeyArgument and io.lettuce.core.protocol.CommandArgs$ValueArgument is consistent. Therefore, it is expected to use addValue to add the Field.
Environment
Possible Solution
Perhaps we can directly use io.lettuce.core.protocol.CommandArgs#addValue to add the field.
Questions
The text was updated successfully, but these errors were encountered: