Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into java/integ_yuryf_LI…
Browse files Browse the repository at this point in the history
…NSERT

Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand committed Apr 10, 2024
2 parents ed36b38 + 4ce976c commit f8dc257
Show file tree
Hide file tree
Showing 32 changed files with 1,273 additions and 631 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* Python: Added HKEYS command ([#1228](https://github.com/aws/glide-for-redis/pull/1228))
* Python: Added ZREMRANGEBYSCORE command ([#1151](https://github.com/aws/glide-for-redis/pull/1151))
* Node: Added SPOP, SPOPCOUNT commands. ([#1117](https://github.com/aws/glide-for-redis/pull/1117))
* Node: Added ZRANGE command ([#1115](https://github.com/aws/glide-for-redis/pull/1115))
* Python: Added RENAME command ([#1252](https://github.com/aws/glide-for-redis/pull/1252))

#### Fixes
* Python: Fix typing error "‘type’ object is not subscriptable" ([#1203](https://github.com/aws/glide-for-redis/pull/1203))
Expand Down
4 changes: 2 additions & 2 deletions glide-core/THIRD_PARTY_LICENSES_RUST
Original file line number Diff line number Diff line change
Expand Up @@ -3451,7 +3451,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

----

Package: bumpalo:3.15.4
Package: bumpalo:3.16.0

The following copyrights and licenses were found in the source code of this package:

Expand Down Expand Up @@ -9734,7 +9734,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

----

Package: getrandom:0.2.13
Package: getrandom:0.2.14

The following copyrights and licenses were found in the source code of this package:

Expand Down
3 changes: 2 additions & 1 deletion glide-core/src/protobuf/redis_request.proto
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ enum RequestType {
LInsert = 101;
RPushX = 102;
LPushX = 103;
ZMScore = 104;
}

message Command {
Expand All @@ -170,7 +171,7 @@ message Transaction {

message RedisRequest {
uint32 callback_idx = 1;

oneof command {
Command single_command = 2;
Transaction transaction = 3;
Expand Down
3 changes: 3 additions & 0 deletions glide-core/src/request_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ pub enum RequestType {
LInsert = 101,
RPushX = 102,
LPushX = 103,
ZMScore = 104,
}

fn get_two_word_command(first: &str, second: &str) -> Cmd {
Expand Down Expand Up @@ -227,6 +228,7 @@ impl From<::protobuf::EnumOrUnknown<ProtobufRequestType>> for RequestType {
ProtobufRequestType::Blpop => RequestType::Blpop,
ProtobufRequestType::LInsert => RequestType::LInsert,
ProtobufRequestType::Spop => RequestType::Spop,
ProtobufRequestType::ZMScore => RequestType::ZMScore,
}
}
}
Expand Down Expand Up @@ -338,6 +340,7 @@ impl RequestType {
RequestType::Blpop => Some(cmd("BLPOP")),
RequestType::LInsert => Some(cmd("LINSERT")),
RequestType::Spop => Some(cmd("SPOP")),
RequestType::ZMScore => Some(cmd("ZMSCORE")),
}
}
}
17 changes: 17 additions & 0 deletions java/client/src/main/java/glide/api/BaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import static redis_request.RedisRequestOuterClass.RequestType.LRange;
import static redis_request.RedisRequestOuterClass.RequestType.LRem;
import static redis_request.RedisRequestOuterClass.RequestType.LTrim;
import static redis_request.RedisRequestOuterClass.RequestType.Lindex;
import static redis_request.RedisRequestOuterClass.RequestType.MGet;
import static redis_request.RedisRequestOuterClass.RequestType.MSet;
import static redis_request.RedisRequestOuterClass.RequestType.PExpire;
Expand All @@ -60,6 +61,7 @@
import static redis_request.RedisRequestOuterClass.RequestType.Type;
import static redis_request.RedisRequestOuterClass.RequestType.Unlink;
import static redis_request.RedisRequestOuterClass.RequestType.XAdd;
import static redis_request.RedisRequestOuterClass.RequestType.ZMScore;
import static redis_request.RedisRequestOuterClass.RequestType.ZPopMax;
import static redis_request.RedisRequestOuterClass.RequestType.ZPopMin;
import static redis_request.RedisRequestOuterClass.RequestType.ZScore;
Expand Down Expand Up @@ -447,6 +449,12 @@ public CompletableFuture<String[]> lrange(@NonNull String key, long start, long
response -> castArray(handleArrayOrNullResponse(response), String.class));
}

@Override
public CompletableFuture<String> lindex(@NonNull String key, long index) {
return commandManager.submitNewCommand(
Lindex, new String[] {key, Long.toString(index)}, this::handleStringOrNullResponse);
}

@Override
public CompletableFuture<String> ltrim(@NonNull String key, long start, long end) {
return commandManager.submitNewCommand(
Expand Down Expand Up @@ -709,6 +717,15 @@ public CompletableFuture<Object[]> zrankWithScore(@NonNull String key, @NonNull
Zrank, new String[] {key, member, WITH_SCORE_REDIS_API}, this::handleArrayOrNullResponse);
}

@Override
public CompletableFuture<Double[]> zmscore(@NonNull String key, @NonNull String[] members) {
String[] arguments = ArrayUtils.addFirst(members, key);
return commandManager.submitNewCommand(
ZMScore,
arguments,
response -> castArray(handleArrayOrNullResponse(response), Double.class));
}

@Override
public CompletableFuture<String> xadd(@NonNull String key, @NonNull Map<String, String> values) {
return xadd(key, values, StreamAddOptions.builder().build());
Expand Down
24 changes: 24 additions & 0 deletions java/client/src/main/java/glide/api/commands/ListBaseCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,30 @@ public interface ListBaseCommands {
*/
CompletableFuture<String[]> lrange(String key, long start, long end);

/**
* Returns the element at <code>index</code> from the list stored at <code>key</code>.<br>
* The index is zero-based, so <code>0</code> means the first element, <code>1</code> the second
* element and so on. Negative indices can be used to designate elements starting at the tail of
* the list. Here, <code>-1</code> means the last element, <code>-2</code> means the penultimate
* and so forth.
*
* @see <a href="https://redis.io/commands/lindex/">redis.io</a> for details.
* @param key The key of the list.
* @param index The index of the element in the list to retrieve.
* @return The element at <code>index</code> in the list stored at <code>key</code>.<br>
* If <code>index</code> is out of range or if <code>key</code> does not exist, <code>null
* </code> is returned.
* @example
* <pre>{@code
* String payload1 = client.lindex("myList", 0).get();
* assert payload1.equals('value1'); // Returns the first element in the list stored at 'myList'.
*
* String payload2 = client.lindex("myList", -1).get();
* assert payload2.equals('value3'); // Returns the last element in the list stored at 'myList'.
* }</pre>
*/
CompletableFuture<String> lindex(String key, long index);

/**
* Trims an existing list so that it will contain only the specified range of elements specified.
* <br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,4 +456,22 @@ CompletableFuture<Map<String, Double>> zrangeWithScores(
* }</pre>
*/
CompletableFuture<Object[]> zrankWithScore(String key, String member);

/**
* Returns the scores associated with the specified <code>members</code> in the sorted set stored
* at <code>key</code>.
*
* @see <a href="https://redis.io/commands/zmscore/">redis.io</a> for more details.
* @param key The key of the sorted set.
* @param members An array of members in the sorted set.
* @return An <code>Array</code> of scores of the <code>members</code>.<br>
* If a <code>member</code> does not exist, the corresponding value in the <code>Array</code>
* will be <code>null</code>.
* @example
* <pre>{@code
* Double[] payload = client.zmscore(key1, new String[] {"one", "nonExistentMember", "three"}).get();
* assert payload.equals(new Double[] {1.0, null, 3.0});
* }</pre>
*/
CompletableFuture<Double[]> zmscore(String key, String[] members);
}
41 changes: 41 additions & 0 deletions java/client/src/main/java/glide/api/models/BaseTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import static redis_request.RedisRequestOuterClass.RequestType.LRange;
import static redis_request.RedisRequestOuterClass.RequestType.LRem;
import static redis_request.RedisRequestOuterClass.RequestType.LTrim;
import static redis_request.RedisRequestOuterClass.RequestType.Lindex;
import static redis_request.RedisRequestOuterClass.RequestType.MGet;
import static redis_request.RedisRequestOuterClass.RequestType.MSet;
import static redis_request.RedisRequestOuterClass.RequestType.PExpire;
Expand All @@ -71,6 +72,7 @@
import static redis_request.RedisRequestOuterClass.RequestType.Type;
import static redis_request.RedisRequestOuterClass.RequestType.Unlink;
import static redis_request.RedisRequestOuterClass.RequestType.XAdd;
import static redis_request.RedisRequestOuterClass.RequestType.ZMScore;
import static redis_request.RedisRequestOuterClass.RequestType.ZPopMax;
import static redis_request.RedisRequestOuterClass.RequestType.ZPopMin;
import static redis_request.RedisRequestOuterClass.RequestType.ZScore;
Expand Down Expand Up @@ -679,6 +681,28 @@ public T lrange(@NonNull String key, long start, long end) {
return getThis();
}

/**
* Returns the element at <code>index</code> from the list stored at <code>key</code>.<br>
* The index is zero-based, so <code>0</code> means the first element, <code>1</code> the second
* element and so on. Negative indices can be used to designate elements starting at the tail of
* the list. Here, <code>-1</code> means the last element, <code>-2</code> means the penultimate
* and so forth.
*
* @see <a href="https://redis.io/commands/lindex/">redis.io</a> for details.
* @param key The key of the list.
* @param index The index of the element in the list to retrieve.
* @return Command Response - The element at <code>index</code> in the list stored at <code>key
* </code>.<br>
* If <code>index</code> is out of range or if <code>key</code> does not exist, <code>null
* </code> is returned.
*/
public T lindex(@NonNull String key, long index) {
ArgsArray commandArgs = buildArgs(key, Long.toString(index));

protobufTransaction.addCommands(buildCommand(Lindex, commandArgs));
return getThis();
}

/**
* Trims an existing list so that it will contain only the specified range of elements specified.<br>
* The offsets <code>start</code> and <code>end</code> are zero-based indexes, with <code>0</code> being the
Expand Down Expand Up @@ -1493,6 +1517,23 @@ public T zrankWithScore(@NonNull String key, @NonNull String member) {
return getThis();
}

/**
* Returns the scores associated with the specified <code>members</code> in the sorted set stored
* at <code>key</code>.
*
* @see <a href="https://redis.io/commands/zmscore/">redis.io</a> for more details.
* @param key The key of the sorted set.
* @param members An array of members in the sorted set.
* @return Command Response - An <code>Array</code> of scores of the <code>members</code>.<br>
* If a <code>member</code> does not exist, the corresponding value in the <code>Array</code>
* will be <code>null</code>.
*/
public T zmscore(@NonNull String key, @NonNull String[] members) {
ArgsArray commandArgs = buildArgs(ArrayUtils.addFirst(members, key));
protobufTransaction.addCommands(buildCommand(ZMScore, commandArgs));
return getThis();
}

/**
* Adds an entry to the specified stream.
*
Expand Down
Loading

0 comments on commit f8dc257

Please sign in to comment.