Skip to content

Commit ee91dc8

Browse files
committed
- fix parameter issues for hashsetand... commands
- add tests
1 parent 8d60413 commit ee91dc8

File tree

8 files changed

+381
-187
lines changed

8 files changed

+381
-187
lines changed

src/StackExchange.Redis/Interfaces/IDatabase.cs

Lines changed: 15 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -565,10 +565,9 @@ public interface IDatabase : IRedis, IDatabaseAsync
565565
/// <param name="key">The key of the hash.</param>
566566
/// <param name="hashField">The field in the hash to get and set the expiration for.</param>
567567
/// <param name="expiry">The exact date and time to set the expiration to.</param>
568-
/// <param name="persist">If true, the expiration will be removed. And 'expiry' parameter is ignored.</param>
569568
/// <param name="flags">The flags to use for this operation.</param>
570569
/// <returns>The value of the specified hash field.</returns>
571-
RedisValue HashFieldGetAndSetExpiry(RedisKey key, RedisValue hashField, DateTime? expiry = null, bool persist = false, CommandFlags flags = CommandFlags.None);
570+
RedisValue HashFieldGetAndSetExpiry(RedisKey key, RedisValue hashField, DateTime expiry, CommandFlags flags = CommandFlags.None);
572571

573572
/// <summary>
574573
/// Gets the value of the specified hash field and sets its expiration time, returning a lease.
@@ -587,10 +586,9 @@ public interface IDatabase : IRedis, IDatabaseAsync
587586
/// <param name="key">The key of the hash.</param>
588587
/// <param name="hashField">The field in the hash to get and set the expiration for.</param>
589588
/// <param name="expiry">The exact date and time to set the expiration to.</param>
590-
/// <param name="persist">If true, the expiration will be removed. And 'expiry' parameter is ignored.</param>
591589
/// <param name="flags">The flags to use for this operation.</param>
592590
/// <returns>The value of the specified hash field as a lease.</returns>
593-
Lease<byte>? HashFieldGetLeaseAndSetExpiry(RedisKey key, RedisValue hashField, DateTime? expiry = null, bool persist = false, CommandFlags flags = CommandFlags.None);
591+
Lease<byte>? HashFieldGetLeaseAndSetExpiry(RedisKey key, RedisValue hashField, DateTime expiry, CommandFlags flags = CommandFlags.None);
594592

595593
/// <summary>
596594
/// Gets the values of the specified hash fields and sets their expiration times.
@@ -609,58 +607,34 @@ public interface IDatabase : IRedis, IDatabaseAsync
609607
/// <param name="key">The key of the hash.</param>
610608
/// <param name="hashFields">The fields in the hash to get and set the expiration for.</param>
611609
/// <param name="expiry">The exact date and time to set the expiration to.</param>
612-
/// <param name="persist">If true, the expiration will be removed. And 'expiry' parameter is ignored.</param>
613610
/// <param name="flags">The flags to use for this operation.</param>
614611
/// <returns>The values of the specified hash fields.</returns>
615-
RedisValue[] HashFieldGetAndSetExpiry(RedisKey key, RedisValue[] hashFields, DateTime? expiry = null, bool persist = false, CommandFlags flags = CommandFlags.None);
612+
RedisValue[] HashFieldGetAndSetExpiry(RedisKey key, RedisValue[] hashFields, DateTime expiry, CommandFlags flags = CommandFlags.None);
616613

617614
/// <summary>
618615
/// Sets the value of the specified hash field and sets its expiration time.
619616
/// </summary>
620617
/// <param name="key">The key of the hash.</param>
621-
/// <param name="hashField">The field in the hash to set and set the expiration for.</param>
618+
/// <param name="field">The field in the hash to set and set the expiration for.</param>
619+
/// <param name="value">The value in the hash to set and set the expiration for.</param>
622620
/// <param name="expiry">The expiration time to set.</param>
623621
/// <param name="keepTtl">Whether to maintain the existing field's TTL (KEEPTTL flag).</param>
624622
/// <param name="when">Which conditions to set the value under (defaults to always).</param>
625623
/// <param name="flags">The flags to use for this operation.</param>
626-
/// <returns>The value of the specified hash field.</returns>
627-
RedisValue HashFieldSetAndSetExpiry(RedisKey key, RedisValue hashField, TimeSpan? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
624+
/// <returns>0 if no fields were set, 1 if all the fields were set.</returns>
625+
RedisValue HashFieldSetAndSetExpiry(RedisKey key, RedisValue field, RedisValue value, TimeSpan? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
628626

629627
/// <summary>
630628
/// Sets the value of the specified hash field and sets its expiration time.
631629
/// </summary>
632630
/// <param name="key">The key of the hash.</param>
633-
/// <param name="hashField">The field in the hash to set and set the expiration for.</param>
631+
/// <param name="field">The field in the hash to set and set the expiration for.</param>
632+
/// <param name="value">The value in the hash to set and set the expiration for.</param>
634633
/// <param name="expiry">The exact date and time to set the expiration to.</param>
635-
/// <param name="keepTtl">Whether to maintain the existing field's TTL (KEEPTTL flag).</param>
636634
/// <param name="when">Which conditions to set the value under (defaults to always).</param>
637635
/// <param name="flags">The flags to use for this operation.</param>
638-
/// <returns>The value of the specified hash field.</returns>
639-
RedisValue HashFieldSetAndSetExpiry(RedisKey key, RedisValue hashField, DateTime? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
640-
641-
/// <summary>
642-
/// Sets the value of the specified hash field and sets its expiration time, returning a lease.
643-
/// </summary>
644-
/// <param name="key">The key of the hash.</param>
645-
/// <param name="hashField">The field in the hash to set and set the expiration for.</param>
646-
/// <param name="expiry">The expiration time to set.</param>
647-
/// <param name="keepTtl">Whether to maintain the existing field's TTL (KEEPTTL flag).</param>
648-
/// <param name="when">Which conditions to set the value under (defaults to always).</param>
649-
/// <param name="flags">The flags to use for this operation.</param>
650-
/// <returns>The value of the specified hash field as a lease.</returns>
651-
Lease<byte>? HashFieldSetLeaseAndSetExpiry(RedisKey key, RedisValue hashField, TimeSpan? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
652-
653-
/// <summary>
654-
/// Sets the value of the specified hash field and sets its expiration time, returning a lease.
655-
/// </summary>
656-
/// <param name="key">The key of the hash.</param>
657-
/// <param name="hashField">The field in the hash to set and set the expiration for.</param>
658-
/// <param name="expiry">The exact date and time to set the expiration to.</param>
659-
/// <param name="keepTtl">Whether to maintain the existing field's TTL (KEEPTTL flag).</param>
660-
/// <param name="when">Which conditions to set the value under (defaults to always).</param>
661-
/// <param name="flags">The flags to use for this operation.</param>
662-
/// <returns>The value of the specified hash field as a lease.</returns>
663-
Lease<byte>? HashFieldSetLeaseAndSetExpiry(RedisKey key, RedisValue hashField, DateTime? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
636+
/// <returns>0 if no fields were set, 1 if all the fields were set.</returns>
637+
RedisValue HashFieldSetAndSetExpiry(RedisKey key, RedisValue field, RedisValue value, DateTime expiry, When when = When.Always, CommandFlags flags = CommandFlags.None);
664638

665639
/// <summary>
666640
/// Sets the values of the specified hash fields and sets their expiration times.
@@ -671,20 +645,19 @@ public interface IDatabase : IRedis, IDatabaseAsync
671645
/// <param name="keepTtl">Whether to maintain the existing fields' TTL (KEEPTTL flag).</param>
672646
/// <param name="when">Which conditions to set the values under (defaults to always).</param>
673647
/// <param name="flags">The flags to use for this operation.</param>
674-
/// <returns>The values of the specified hash fields.</returns>
675-
RedisValue[] HashFieldSetAndSetExpiry(RedisKey key, RedisValue[] hashFields, TimeSpan? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
648+
/// <returns>0 if no fields were set, 1 if all the fields were set.</returns>
649+
RedisValue HashFieldSetAndSetExpiry(RedisKey key, HashEntry[] hashFields, TimeSpan? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
676650

677651
/// <summary>
678652
/// Sets the values of the specified hash fields and sets their expiration times.
679653
/// </summary>
680654
/// <param name="key">The key of the hash.</param>
681655
/// <param name="hashFields">The fields in the hash to set and set the expiration for.</param>
682656
/// <param name="expiry">The exact date and time to set the expiration to.</param>
683-
/// <param name="keepTtl">Whether to maintain the existing fields' TTL (KEEPTTL flag).</param>
684657
/// <param name="when">Which conditions to set the values under (defaults to always).</param>
685658
/// <param name="flags">The flags to use for this operation.</param>
686-
/// <returns>The values of the specified hash fields.</returns>
687-
RedisValue[] HashFieldSetAndSetExpiry(RedisKey key, RedisValue[] hashFields, DateTime? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
659+
/// <returns>0 if no fields were set, 1 if all the fields were set.</returns>
660+
RedisValue HashFieldSetAndSetExpiry(RedisKey key, HashEntry[] hashFields, DateTime expiry, When when = When.Always, CommandFlags flags = CommandFlags.None);
688661

689662
/// <summary>
690663
/// Returns all fields and values of the hash stored at key.

src/StackExchange.Redis/Interfaces/IDatabaseAsync.cs

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,38 +96,32 @@ public interface IDatabaseAsync : IRedisAsync
9696
/// <inheritdoc cref="IDatabase.HashFieldGetAndSetExpiry(RedisKey, RedisValue, TimeSpan?, bool, CommandFlags)"/>
9797
Task<RedisValue> HashFieldGetAndSetExpiryAsync(RedisKey key, RedisValue hashField, TimeSpan? expiry = null, bool persist = false, CommandFlags flags = CommandFlags.None);
9898

99-
/// <inheritdoc cref="IDatabase.HashFieldGetAndSetExpiry(RedisKey, RedisValue, DateTime?, bool, CommandFlags)"/>
100-
Task<RedisValue> HashFieldGetAndSetExpiryAsync(RedisKey key, RedisValue hashField, DateTime? expiry = null, bool persist = false, CommandFlags flags = CommandFlags.None);
99+
/// <inheritdoc cref="IDatabase.HashFieldGetAndSetExpiry(RedisKey, RedisValue, DateTime, CommandFlags)"/>
100+
Task<RedisValue> HashFieldGetAndSetExpiryAsync(RedisKey key, RedisValue hashField, DateTime expiry, CommandFlags flags = CommandFlags.None);
101101

102102
/// <inheritdoc cref="IDatabase.HashFieldGetLeaseAndSetExpiry(RedisKey, RedisValue, TimeSpan?, bool, CommandFlags)"/>
103103
Task<Lease<byte>?> HashFieldGetLeaseAndSetExpiryAsync(RedisKey key, RedisValue hashField, TimeSpan? expiry = null, bool persist = false, CommandFlags flags = CommandFlags.None);
104104

105-
/// <inheritdoc cref="IDatabase.HashFieldGetLeaseAndSetExpiry(RedisKey, RedisValue, DateTime?, bool, CommandFlags)"/>
106-
Task<Lease<byte>?> HashFieldGetLeaseAndSetExpiryAsync(RedisKey key, RedisValue hashField, DateTime? expiry = null, bool persist = false, CommandFlags flags = CommandFlags.None);
105+
/// <inheritdoc cref="IDatabase.HashFieldGetLeaseAndSetExpiry(RedisKey, RedisValue, DateTime, CommandFlags)"/>
106+
Task<Lease<byte>?> HashFieldGetLeaseAndSetExpiryAsync(RedisKey key, RedisValue hashField, DateTime expiry, CommandFlags flags = CommandFlags.None);
107107

108108
/// <inheritdoc cref="IDatabase.HashFieldGetAndSetExpiry(RedisKey, RedisValue[], TimeSpan?, bool, CommandFlags)"/>
109109
Task<RedisValue[]> HashFieldGetAndSetExpiryAsync(RedisKey key, RedisValue[] hashFields, TimeSpan? expiry = null, bool persist = false, CommandFlags flags = CommandFlags.None);
110110

111-
/// <inheritdoc cref="IDatabase.HashFieldGetAndSetExpiry(RedisKey, RedisValue[], DateTime?, bool, CommandFlags)"/>
112-
Task<RedisValue[]> HashFieldGetAndSetExpiryAsync(RedisKey key, RedisValue[] hashFields, DateTime? expiry = null, bool persist = false, CommandFlags flags = CommandFlags.None);
111+
/// <inheritdoc cref="IDatabase.HashFieldGetAndSetExpiry(RedisKey, RedisValue[], DateTime, CommandFlags)"/>
112+
Task<RedisValue[]> HashFieldGetAndSetExpiryAsync(RedisKey key, RedisValue[] hashFields, DateTime expiry, CommandFlags flags = CommandFlags.None);
113113

114-
/// <inheritdoc cref="IDatabase.HashFieldSetAndSetExpiry(RedisKey, RedisValue, TimeSpan?, bool, When, CommandFlags)"/>
115-
Task<RedisValue> HashFieldSetAndSetExpiryAsync(RedisKey key, RedisValue hashField, TimeSpan? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
114+
/// <inheritdoc cref="IDatabase.HashFieldSetAndSetExpiry(RedisKey, RedisValue, RedisValue, TimeSpan?, bool, When, CommandFlags)"/>
115+
Task<RedisValue> HashFieldSetAndSetExpiryAsync(RedisKey key, RedisValue field, RedisValue value, TimeSpan? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
116116

117-
/// <inheritdoc cref="IDatabase.HashFieldSetAndSetExpiry(RedisKey, RedisValue, DateTime?, bool, When, CommandFlags)"/>
118-
Task<RedisValue> HashFieldSetAndSetExpiryAsync(RedisKey key, RedisValue hashField, DateTime? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
117+
/// <inheritdoc cref="IDatabase.HashFieldSetAndSetExpiry(RedisKey, RedisValue, RedisValue, DateTime, When, CommandFlags)"/>
118+
Task<RedisValue> HashFieldSetAndSetExpiryAsync(RedisKey key, RedisValue field, RedisValue value, DateTime expiry, When when = When.Always, CommandFlags flags = CommandFlags.None);
119119

120-
/// <inheritdoc cref="IDatabase.HashFieldSetLeaseAndSetExpiry(RedisKey, RedisValue, TimeSpan?, bool, When, CommandFlags)"/>
121-
Task<Lease<byte>?> HashFieldSetLeaseAndSetExpiryAsync(RedisKey key, RedisValue hashField, TimeSpan? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
120+
/// <inheritdoc cref="IDatabase.HashFieldSetAndSetExpiry(RedisKey, HashEntry[], TimeSpan?, bool, When, CommandFlags)"/>
121+
Task<RedisValue> HashFieldSetAndSetExpiryAsync(RedisKey key, HashEntry[] hashFields, TimeSpan? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
122122

123-
/// <inheritdoc cref="IDatabase.HashFieldSetLeaseAndSetExpiry(RedisKey, RedisValue, DateTime?, bool, When, CommandFlags)"/>
124-
Task<Lease<byte>?> HashFieldSetLeaseAndSetExpiryAsync(RedisKey key, RedisValue hashField, DateTime? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
125-
126-
/// <inheritdoc cref="IDatabase.HashFieldSetAndSetExpiry(RedisKey, RedisValue[], TimeSpan?, bool, When, CommandFlags)"/>
127-
Task<RedisValue[]> HashFieldSetAndSetExpiryAsync(RedisKey key, RedisValue[] hashFields, TimeSpan? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
128-
129-
/// <inheritdoc cref="IDatabase.HashFieldSetAndSetExpiry(RedisKey, RedisValue[], DateTime?, bool, When, CommandFlags)"/>
130-
Task<RedisValue[]> HashFieldSetAndSetExpiryAsync(RedisKey key, RedisValue[] hashFields, DateTime? expiry = null, bool keepTtl = false, When when = When.Always, CommandFlags flags = CommandFlags.None);
123+
/// <inheritdoc cref="IDatabase.HashFieldSetAndSetExpiry(RedisKey, HashEntry[], DateTime, When, CommandFlags)"/>
124+
Task<RedisValue> HashFieldSetAndSetExpiryAsync(RedisKey key, HashEntry[] hashFields, DateTime expiry, When when = When.Always, CommandFlags flags = CommandFlags.None);
131125

132126
/// <inheritdoc cref="IDatabase.HashFieldExpire(RedisKey, RedisValue[], TimeSpan, ExpireWhen, CommandFlags)"/>
133127
Task<ExpireResult[]> HashFieldExpireAsync(RedisKey key, RedisValue[] hashFields, TimeSpan expiry, ExpireWhen when = ExpireWhen.Always, CommandFlags flags = CommandFlags.None);

0 commit comments

Comments
 (0)