|
| 1 | +// Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 |
| 2 | + |
| 3 | +namespace Valkey.Glide; |
| 4 | + |
| 5 | +/// <summary> |
| 6 | +/// Represents a group of operations that will be sent to the server as a single unit, |
| 7 | +/// and processed on the server as a single unit. Transactions can also include constraints |
| 8 | +/// (implemented via <c>WATCH</c>), but note that constraint checking involves will (very briefly) |
| 9 | +/// block the connection, since the transaction cannot be correctly committed (<c>EXEC</c>), |
| 10 | +/// aborted (<c>DISCARD</c>) or not applied in the first place (<c>UNWATCH</c>) until the responses from |
| 11 | +/// the constraint checks have arrived. |
| 12 | +/// See also <see cref="Pipeline.Batch" /> and <see cref="Pipeline.ClusterBatch" />. |
| 13 | +/// </summary> |
| 14 | +/// <remarks> |
| 15 | +/// <para>Note that on a cluster, it may be required that all keys involved in the transaction (including constraints) are in the same hash-slot.</para> |
| 16 | +/// <para><seealso href="https://valkey.io/topics/transactions/"/></para> |
| 17 | +/// </remarks> |
| 18 | +public interface ITransaction : IBatch |
| 19 | +{ |
| 20 | + /// <summary> |
| 21 | + /// Adds a precondition for this transaction. |
| 22 | + /// </summary> |
| 23 | + /// <param name="condition">The condition to add to the transaction.</param> |
| 24 | + //ConditionResult AddCondition(Condition condition); |
| 25 | + |
| 26 | + /// <summary> |
| 27 | + /// Execute the batch operation, sending all queued commands to the server. |
| 28 | + /// </summary> |
| 29 | + /// <param name="flags">Command flags are not supported by GLIDE.</param> |
| 30 | + /// <returns> |
| 31 | + /// <see langword="true" /> if a transaction was applied or |
| 32 | + /// <see langword="false" /> if a transaction failed due to a <c>WATCH</c> command. |
| 33 | + /// </returns> |
| 34 | + bool Execute(CommandFlags flags = CommandFlags.None); |
| 35 | + |
| 36 | + /// <summary> |
| 37 | + /// Execute the batch operation, sending all queued commands to the server. |
| 38 | + /// </summary> |
| 39 | + /// <param name="flags">Command flags are not supported by GLIDE.</param> |
| 40 | + /// <returns> |
| 41 | + /// <see langword="true" /> if a transaction was applied or |
| 42 | + /// <see langword="false" /> if a transaction failed due to a <c>WATCH</c> command. |
| 43 | + /// </returns> |
| 44 | + Task<bool> ExecuteAsync(CommandFlags flags = CommandFlags.None); |
| 45 | +} |
0 commit comments