-
Notifications
You must be signed in to change notification settings - Fork 612
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
ISPN-14659 STRLEN command #10932
ISPN-14659 STRLEN command #10932
Conversation
byte[] keyBytes = arguments.get(0); | ||
|
||
CompletableFuture<Long> strLenAsync = handler.cache().getAsync(keyBytes) | ||
.thenCompose(buff -> CompletableFuture.completedFuture(Long.valueOf(buff!=null ? buff.length : 0))); |
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.
Don't use thenCompose for synchronous invocations, just use thenApply
.
.thenCompose(buff -> CompletableFuture.completedFuture(Long.valueOf(buff!=null ? buff.length : 0))); | |
.thenApply(buff -> buff!=null ? buff.length : 0L); |
RedisCommands<String, String> redis = redisConnection.sync(); | ||
String key = "strlen"; | ||
String val = "Hello"; | ||
String app = " World"; |
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.
This test needs to test non ASCII characters as well, and verify the behavior with REDIS server. Unfortunately, https://redis.io/commands/strlen/ doesn't state what it does for non UTF-8 characters if it counts the bytes or the characters. (I have a feeling it may be the latter).
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.
Added test. Redis strings are sequence of bytes, so it counts bytes:
127.0.0.1:6379> set euro "€"
OK
127.0.0.1:6379> strlen euro
(integer) 3
Integrated into main, thanks @rigazilla ! |
STRLEN command
https://issues.redhat.com/browse/ISPN-14659