Home / node / Commands / type-aliases / ClusterBatchOptions @valkey/valkey-glide
@valkey/valkey-glide / Commands / ClusterBatchOptions
Type Alias: ClusterBatchOptions
ClusterBatchOptions =
object&BaseBatchOptions
Options for a batch request for a cluster client.
Route
Configures single-node routing for the batch request. The client will send the batch to the
specified node defined by route.
Retry Strategy
⚠️ Please read ClusterBatchRetryStrategy carefully before enabling these configurations. Defines the retry strategy for handling batch request failures.
This strategy determines whether failed commands should be retried, potentially impacting execution order.
- If
retryServerErroristrue, retriable errors (e.g.,TRYAGAIN) will trigger a retry. - If
retryConnectionErroristrue, connection failures will trigger a retry.
⚠️ Warnings:
- Retrying server errors may cause commands targeting the same slot to execute out of order.
- Retrying connection errors may lead to duplicate executions, as it is unclear which commands have already been processed.
Note: Currently, retry strategies are supported only for non-atomic batches.
Recommendation: It is recommended to increase the timeout in BaseBatchOptions when enabling these strategies.
Default: Both retryServerError and retryConnectionError are set to false.
Type declaration
retryStrategy?
optionalretryStrategy:ClusterBatchRetryStrategy
⚠️ Please see ClusterBatchRetryStrategy and read carefully before enabling these configurations.
Defines the retry strategy for handling batch request failures.
This strategy determines whether failed commands should be retried, potentially impacting execution order.
- If
retryServerErroristrue, retriable errors (e.g.,TRYAGAIN) will trigger a retry. - If
retryConnectionErroristrue, connection failures will trigger a retry.
⚠️ Warnings:
- Retrying server errors may cause commands targeting the same slot to execute out of order.
- Retrying connection errors may lead to duplicate executions, as it is unclear which commands have already been processed.
Note: Currently, retry strategies are supported only for non-atomic batches.
Recommendation: It is recommended to increase the timeout in BaseBatchOptions when enabling these strategies.
Default: Both retryServerError and retryConnectionError are set to false.
route?
optionalroute:SingleNodeRoute
Configures single-node routing for the batch request. The client will send the batch to the
specified node defined by route.
If a redirection error occurs:
- For Atomic Batches (Transactions), the entire transaction will be redirected.
- For Non-Atomic Batches (Pipelines), only the commands that encountered redirection errors will be redirected.
Example
const options: ClusterBatchOptions = {
timeout: 5000, // 5 seconds
route: "randomNode",
retryStrategy: {
retryServerError: false,
retryConnectionError: false,
},
};