Skip to content

Commit

Permalink
Merge branch 'release-1.2' into dont_lock_on_reconnect
Browse files Browse the repository at this point in the history
Signed-off-by: Bar Shaul <[email protected]>
  • Loading branch information
barshaul authored Nov 7, 2024
2 parents cb1f91a + ae133d9 commit c9b3a5b
Show file tree
Hide file tree
Showing 29 changed files with 786 additions and 337 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
* Node: Add `JSON.STRLEN` and `JSON.STRAPPEND` command ([#2537](https://github.com/valkey-io/valkey-glide/pull/2537))
* Node: Add `FT.SEARCH` ([#2551](https://github.com/valkey-io/valkey-glide/pull/2551))
* Python: Fix example ([#2556](https://github.com/valkey-io/valkey-glide/issues/2556))
* Core: Add support for sending multi-slot JSON.MSET and JSON.MGET commands ([#2587]https://github.com/valkey-io/valkey-glide/pull/2587)
* Core: Release the read lock while creating connections in `refresh_connections` ([#2630](https://github.com/valkey-io/valkey-glide/issues/2630))

#### Breaking Changes
Expand Down
7 changes: 4 additions & 3 deletions glide-core/redis-rs/redis/src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ where
let mut slots = self.slots.borrow_mut();

let results = match &routing {
MultipleNodeRoutingInfo::MultiSlot(routes) => {
MultipleNodeRoutingInfo::MultiSlot((routes, _)) => {
self.execute_multi_slot(input, &mut slots, &mut connections, routes)
}
MultipleNodeRoutingInfo::AllMasters => {
Expand Down Expand Up @@ -648,10 +648,11 @@ where
.map(|res| res.map(|(_, val)| val))
.collect::<RedisResult<Vec<_>>>()?;
match routing {
MultipleNodeRoutingInfo::MultiSlot(vec) => {
MultipleNodeRoutingInfo::MultiSlot((vec, args_pattern)) => {
crate::cluster_routing::combine_and_sort_array_results(
results,
vec.iter().map(|(_, indices)| indices),
&vec,
&args_pattern,
)
}
_ => crate::cluster_routing::combine_array_results(results),
Expand Down
7 changes: 4 additions & 3 deletions glide-core/redis-rs/redis/src/cluster_async/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1439,10 +1439,11 @@ where
future::try_join_all(receivers.into_iter().map(get_receiver))
.await
.and_then(|results| match routing {
MultipleNodeRoutingInfo::MultiSlot(vec) => {
MultipleNodeRoutingInfo::MultiSlot((vec, args_pattern)) => {
crate::cluster_routing::combine_and_sort_array_results(
results,
vec.iter().map(|(_, indices)| indices),
vec,
args_pattern,
)
}
_ => crate::cluster_routing::combine_array_results(results),
Expand Down Expand Up @@ -1893,7 +1894,7 @@ where
.all_primary_connections()
.map(|tuple| Some((cmd.clone(), tuple))),
),
MultipleNodeRoutingInfo::MultiSlot(slots) => {
MultipleNodeRoutingInfo::MultiSlot((slots, _)) => {
into_channels(slots.iter().map(|(route, indices)| {
connections_container
.connection_for_route(route)
Expand Down
540 changes: 484 additions & 56 deletions glide-core/redis-rs/redis/src/cluster_routing.rs

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions go/api/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,12 @@ type StringCommands interface {
// Sets multiple keys to multiple values in a single operation.
//
// Note:
// When in cluster mode, the command may route to multiple nodes when keys in keyValueMap map to different hash slots.
//
// See [valkey.io] for details.
// In cluster mode, if keys in `keyValueMap` map to different hash slots, the command
// will be split across these slots and executed separately for each. This means the command
// is atomic only at the slot level. If one or more slot-specific requests fail, the entire
// call will return the first encountered error, even though some requests may have succeeded
// while others did not. If this behavior impacts your application logic, consider splitting
// the request into sub-requests per slot to ensure atomicity.
//
// Parameters:
// keyValueMap - A key-value map consisting of keys and their respective values to set.
Expand All @@ -153,9 +156,12 @@ type StringCommands interface {
// Retrieves the values of multiple keys.
//
// Note:
// When in cluster mode, the command may route to multiple nodes when keys map to different hash slots.
//
// See [valkey.io] for details.
// In cluster mode, if keys in `keys` map to different hash slots, the command
// will be split across these slots and executed separately for each. This means the command
// is atomic only at the slot level. If one or more slot-specific requests fail, the entire
// call will return the first encountered error, even though some requests may have succeeded
// while others did not. If this behavior impacts your application logic, consider splitting
// the request into sub-requests per slot to ensure atomicity.
//
// Parameters:
// keys - A list of keys to retrieve values for.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ public interface GenericBaseCommands {
* Removes the specified <code>keys</code> from the database. A key is ignored if it does not
* exist.
*
* @apiNote When in cluster mode, the command may route to multiple nodes when <code>keys</code>
* map to different hash slots.
* @apiNote In cluster mode, if keys in <code>keys</code> map to different hash slots, the command
* will be split across these slots and executed separately for each. This means the command
* is atomic only at the slot level. If one or more slot-specific requests fail, the entire
* call will return the first encountered error, even though some requests may have succeeded
* while others did not. If this behavior impacts your application logic, consider splitting
* the request into sub-requests per slot to ensure atomicity.
* @see <a href="https://valkey.io/commands/del/">valkey.io</a> for details.
* @param keys The keys we wanted to remove.
* @return The number of keys that were removed.
Expand All @@ -40,8 +44,12 @@ public interface GenericBaseCommands {
* Removes the specified <code>keys</code> from the database. A key is ignored if it does not
* exist.
*
* @apiNote When in cluster mode, the command may route to multiple nodes when <code>keys</code>
* map to different hash slots.
* @apiNote In cluster mode, if keys in <code>keys</code> map to different hash slots, the command
* will be split across these slots and executed separately for each. This means the command
* is atomic only at the slot level. If one or more slot-specific requests fail, the entire
* call will return the first encountered error, even though some requests may have succeeded
* while others did not. If this behavior impacts your application logic, consider splitting
* the request into sub-requests per slot to ensure atomicity.
* @see <a href="https://valkey.io/commands/del/">valkey.io</a> for details.
* @param keys The keys we wanted to remove.
* @return The number of keys that were removed.
Expand All @@ -56,8 +64,12 @@ public interface GenericBaseCommands {
/**
* Returns the number of keys in <code>keys</code> that exist in the database.
*
* @apiNote When in cluster mode, the command may route to multiple nodes when <code>keys</code>
* map to different hash slots.
* @apiNote In cluster mode, if keys in <code>keys</code> map to different hash slots, the command
* will be split across these slots and executed separately for each. This means the command
* is atomic only at the slot level. If one or more slot-specific requests fail, the entire
* call will return the first encountered error, even though some requests may have succeeded
* while others did not. If this behavior impacts your application logic, consider splitting
* the request into sub-requests per slot to ensure atomicity.
* @see <a href="https://valkey.io/commands/exists/">valkey.io</a> for details.
* @param keys The keys list to check.
* @return The number of keys that exist. If the same existing key is mentioned in <code>keys
Expand All @@ -73,8 +85,12 @@ public interface GenericBaseCommands {
/**
* Returns the number of keys in <code>keys</code> that exist in the database.
*
* @apiNote When in cluster mode, the command may route to multiple nodes when <code>keys</code>
* map to different hash slots.
* @apiNote In cluster mode, if keys in <code>keys</code> map to different hash slots, the command
* will be split across these slots and executed separately for each. This means the command
* is atomic only at the slot level. If one or more slot-specific requests fail, the entire
* call will return the first encountered error, even though some requests may have succeeded
* while others did not. If this behavior impacts your application logic, consider splitting
* the request into sub-requests per slot to ensure atomicity.
* @see <a href="https://valkey.io/commands/exists/">valkey.io</a> for details.
* @param keys The keys list to check.
* @return The number of keys that exist. If the same existing key is mentioned in <code>keys
Expand All @@ -93,8 +109,12 @@ public interface GenericBaseCommands {
* specified keys and ignores non-existent ones. However, this command does not block the server,
* while <a href="https://valkey.io/commands/del/">DEL</a> does.
*
* @apiNote When in cluster mode, the command may route to multiple nodes when <code>keys</code>
* map to different hash slots.
* @apiNote In cluster mode, if keys in <code>keys</code> map to different hash slots, the command
* will be split across these slots and executed separately for each. This means the command
* is atomic only at the slot level. If one or more slot-specific requests fail, the entire
* call will return the first encountered error, even though some requests may have succeeded
* while others did not. If this behavior impacts your application logic, consider splitting
* the request into sub-requests per slot to ensure atomicity.
* @see <a href="https://valkey.io/commands/unlink/">valkey.io</a> for details.
* @param keys The list of keys to unlink.
* @return The number of <code>keys</code> that were unlinked.
Expand All @@ -112,8 +132,12 @@ public interface GenericBaseCommands {
* specified keys and ignores non-existent ones. However, this command does not block the server,
* while <a href="https://valkey.io/commands/del/">DEL</a> does.
*
* @apiNote When in cluster mode, the command may route to multiple nodes when <code>keys</code>
* map to different hash slots.
* @apiNote In cluster mode, if keys in <code>keys</code> map to different hash slots, the command
* will be split across these slots and executed separately for each. This means the command
* is atomic only at the slot level. If one or more slot-specific requests fail, the entire
* call will return the first encountered error, even though some requests may have succeeded
* while others did not. If this behavior impacts your application logic, consider splitting
* the request into sub-requests per slot to ensure atomicity.
* @see <a href="https://valkey.io/commands/unlink/">valkey.io</a> for details.
* @param keys The list of keys to unlink.
* @return The number of <code>keys</code> that were unlinked.
Expand Down Expand Up @@ -952,8 +976,12 @@ CompletableFuture<Boolean> pexpireAt(
/**
* Updates the last access time of specified <code>keys</code>.
*
* @apiNote When in cluster mode, the command may route to multiple nodes when <code>keys</code>
* map to different hash slots.
* @apiNote In cluster mode, if keys in <code>keys</code> map to different hash slots, the command
* will be split across these slots and executed separately for each. This means the command
* is atomic only at the slot level. If one or more slot-specific requests fail, the entire
* call will return the first encountered error, even though some requests may have succeeded
* while others did not. If this behavior impacts your application logic, consider splitting
* the request into sub-requests per slot to ensure atomicity.
* @see <a href="https://valkey.io/commands/touch/">valkey.io</a> for details.
* @param keys The keys to update last access time.
* @return The number of keys that were updated.
Expand All @@ -968,8 +996,12 @@ CompletableFuture<Boolean> pexpireAt(
/**
* Updates the last access time of specified <code>keys</code>.
*
* @apiNote When in cluster mode, the command may route to multiple nodes when <code>keys</code>
* map to different hash slots.
* @apiNote In cluster mode, if keys in <code>keys</code> map to different hash slots, the command
* will be split across these slots and executed separately for each. This means the command
* is atomic only at the slot level. If one or more slot-specific requests fail, the entire
* call will return the first encountered error, even though some requests may have succeeded
* while others did not. If this behavior impacts your application logic, consider splitting
* the request into sub-requests per slot to ensure atomicity.
* @see <a href="https://valkey.io/commands/touch/">valkey.io</a> for details.
* @param keys The keys to update last access time.
* @return The number of keys that were updated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,12 @@ public interface StringBaseCommands {
/**
* Retrieves the values of multiple <code>keys</code>.
*
* @apiNote When in cluster mode, the command may route to multiple nodes when <code>keys</code>
* map to different hash slots.
* @apiNote In cluster mode, if keys in <code>keys</code> map to different hash slots, the command
* will be split across these slots and executed separately for each. This means the command
* is atomic only at the slot level. If one or more slot-specific requests fail, the entire
* call will return the first encountered error, even though some requests may have succeeded
* while others did not. If this behavior impacts your application logic, consider splitting
* the request into sub-requests per slot to ensure atomicity.
* @see <a href="https://valkey.io/commands/mget/">valkey.io</a> for details.
* @param keys A list of keys to retrieve values for.
* @return An array of values corresponding to the provided <code>keys</code>.<br>
Expand All @@ -267,8 +271,12 @@ public interface StringBaseCommands {
/**
* Retrieves the values of multiple <code>keys</code>.
*
* @apiNote When in cluster mode, the command may route to multiple nodes when <code>keys</code>
* map to different hash slots.
* @apiNote In cluster mode, if keys in <code>keys</code> map to different hash slots, the command
* will be split across these slots and executed separately for each. This means the command
* is atomic only at the slot level. If one or more slot-specific requests fail, the entire
* call will return the first encountered error, even though some requests may have succeeded
* while others did not. If this behavior impacts your application logic, consider splitting
* the request into sub-requests per slot to ensure atomicity.
* @see <a href="https://valkey.io/commands/mget/">valkey.io</a> for details.
* @param keys A list of keys to retrieve values for.
* @return An array of values corresponding to the provided <code>keys</code>.<br>
Expand All @@ -285,11 +293,15 @@ public interface StringBaseCommands {
/**
* Sets multiple keys to multiple values in a single operation.
*
* @apiNote When in cluster mode, the command may route to multiple nodes when keys in <code>
* keyValueMap</code> map to different hash slots.
* @apiNote In cluster mode, if keys in <code>keyValueMap</code> map to different hash slots, the
* command will be split across these slots and executed separately for each. This means the
* command is atomic only at the slot level. If one or more slot-specific requests fail, the
* entire call will return the first encountered error, even though some requests may have
* succeeded while others did not. If this behavior impacts your application logic, consider
* splitting the request into sub-requests per slot to ensure atomicity.
* @see <a href="https://valkey.io/commands/mset/">valkey.io</a> for details.
* @param keyValueMap A key-value map consisting of keys and their respective values to set.
* @return Always <code>OK</code>.
* @return A simple <code>OK</code> response.
* @example
* <pre>{@code
* String result = client.mset(Map.of("key1", "value1", "key2", "value2"}).get();
Expand All @@ -301,11 +313,15 @@ public interface StringBaseCommands {
/**
* Sets multiple keys to multiple values in a single operation.
*
* @apiNote When in cluster mode, the command may route to multiple nodes when keys in <code>
* keyValueMap</code> map to different hash slots.
* @apiNote In cluster mode, if keys in <code>keyValueMap</code> map to different hash slots, the
* command will be split across these slots and executed separately for each. This means the
* command is atomic only at the slot level. If one or more slot-specific requests fail, the
* entire call will return the first encountered error, even though some requests may have
* succeeded while others did not. If this behavior impacts your application logic, consider
* splitting the request into sub-requests per slot to ensure atomicity.
* @see <a href="https://valkey.io/commands/mset/">valkey.io</a> for details.
* @param keyValueMap A key-value map consisting of keys and their respective values to set.
* @return Always <code>OK</code>.
* @return A simple <code>OK</code> response.
* @example
* <pre>{@code
* String result = client.msetBinary(Map.of(gs("key1"), gs("value1"), gs("key2"), gs("value2")}).get();
Expand Down
Loading

0 comments on commit c9b3a5b

Please sign in to comment.