Skip to content

Commit 940e7aa

Browse files
committed
add support for hscan novalues option
1 parent 61c13c2 commit 940e7aa

File tree

10 files changed

+299
-55
lines changed

10 files changed

+299
-55
lines changed

src/StackExchange.Redis/Interfaces/IDatabase.cs

+26-1
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,31 @@ public interface IDatabase : IRedis, IDatabaseAsync
469469
/// <remarks><seealso href="https://redis.io/commands/hscan"/></remarks>
470470
IEnumerable<HashEntry> HashScan(RedisKey key, RedisValue pattern = default, int pageSize = RedisBase.CursorUtils.DefaultLibraryPageSize, long cursor = RedisBase.CursorUtils.Origin, int pageOffset = 0, CommandFlags flags = CommandFlags.None);
471471

472+
/// <summary>
473+
/// The HSCAN command is used to incrementally iterate over a hash and return only field names.
474+
/// </summary>
475+
/// <param name="key">The key of the hash.</param>
476+
/// <param name="pattern">The pattern of keys to get entries for.</param>
477+
/// <param name="pageSize">The page size to iterate by.</param>
478+
/// <param name="flags">The flags to use for this operation.</param>
479+
/// <returns>Yields all elements of the hash matching the pattern.</returns>
480+
/// <remarks><seealso href="https://redis.io/commands/hscan"/></remarks>
481+
IEnumerable<RedisValue> HashScanNoValues(RedisKey key, RedisValue pattern, int pageSize, CommandFlags flags);
482+
483+
/// <summary>
484+
/// The HSCAN command is used to incrementally iterate over a hash and return only field names.
485+
/// Note: to resume an iteration via <i>cursor</i>, cast the original enumerable or enumerator to <see cref="IScanningCursor"/>.
486+
/// </summary>
487+
/// <param name="key">The key of the hash.</param>
488+
/// <param name="pattern">The pattern of keys to get entries for.</param>
489+
/// <param name="pageSize">The page size to iterate by.</param>
490+
/// <param name="cursor">The cursor position to start at.</param>
491+
/// <param name="pageOffset">The page offset to start at.</param>
492+
/// <param name="flags">The flags to use for this operation.</param>
493+
/// <returns>Yields all elements of the hash matching the pattern.</returns>
494+
/// <remarks><seealso href="https://redis.io/commands/hscan"/></remarks>
495+
IEnumerable<RedisValue> HashScanNoValues(RedisKey key, RedisValue pattern = default, int pageSize = RedisBase.CursorUtils.DefaultLibraryPageSize, long cursor = RedisBase.CursorUtils.Origin, int pageOffset = 0, CommandFlags flags = CommandFlags.None);
496+
472497
/// <summary>
473498
/// Sets the specified fields to their respective values in the hash stored at key.
474499
/// This command overwrites any specified fields that already exist in the hash, leaving other unspecified fields untouched.
@@ -1628,7 +1653,7 @@ public interface IDatabase : IRedis, IDatabaseAsync
16281653

16291654
/// <inheritdoc cref="SortedSetAdd(RedisKey, RedisValue, double, SortedSetWhen, CommandFlags)" />
16301655
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
1631-
bool SortedSetAdd(RedisKey key, RedisValue member, double score, When when, CommandFlags flags= CommandFlags.None);
1656+
bool SortedSetAdd(RedisKey key, RedisValue member, double score, When when, CommandFlags flags = CommandFlags.None);
16321657

16331658
/// <summary>
16341659
/// Adds the specified member with the specified score to the sorted set stored at key.

src/StackExchange.Redis/Interfaces/IDatabaseAsync.cs

+15
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,21 @@ public interface IDatabaseAsync : IRedisAsync
445445
/// <remarks><seealso href="https://redis.io/commands/hscan"/></remarks>
446446
IAsyncEnumerable<HashEntry> HashScanAsync(RedisKey key, RedisValue pattern = default, int pageSize = RedisBase.CursorUtils.DefaultLibraryPageSize, long cursor = RedisBase.CursorUtils.Origin, int pageOffset = 0, CommandFlags flags = CommandFlags.None);
447447

448+
/// <summary>
449+
/// The HSCAN command is used to incrementally iterate over a hash and get the fields without values
450+
/// Note: to resume an iteration via <i>cursor</i>, cast the original enumerable or enumerator to <see cref="IScanningCursor"/>.
451+
/// </summary>
452+
/// <param name="key">The key of the hash.</param>
453+
/// <param name="pattern">The pattern of keys to get entries for.</param>
454+
/// <param name="pageSize">The page size to iterate by.</param>
455+
/// <param name="cursor">The cursor position to start at.</param>
456+
/// <param name="pageOffset">The page offset to start at.</param>
457+
/// <param name="flags">The flags to use for this operation.</param>
458+
/// <returns>Yields all field names of hash matching the pattern .</returns>
459+
/// <remarks><seealso href="https://redis.io/commands/hscan"/></remarks>
460+
IAsyncEnumerable<RedisValue> HashScanNoValuesAsync(RedisKey key, RedisValue pattern = default, int pageSize = RedisBase.CursorUtils.DefaultLibraryPageSize, long cursor = RedisBase.CursorUtils.Origin, int pageOffset = 0, CommandFlags flags = CommandFlags.None);
461+
462+
448463
/// <summary>
449464
/// Sets the specified fields to their respective values in the hash stored at key.
450465
/// This command overwrites any specified fields that already exist in the hash, leaving other unspecified fields untouched.

src/StackExchange.Redis/KeyspaceIsolation/KeyPrefixed.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ public Task<RedisValue[]> HashRandomFieldsAsync(RedisKey key, long count, Comman
117117
public Task<HashEntry[]> HashRandomFieldsWithValuesAsync(RedisKey key, long count, CommandFlags flags = CommandFlags.None) =>
118118
Inner.HashRandomFieldsWithValuesAsync(ToInner(key), count, flags);
119119

120-
121120
public IAsyncEnumerable<HashEntry> HashScanAsync(RedisKey key, RedisValue pattern, int pageSize, long cursor, int pageOffset, CommandFlags flags) =>
122121
Inner.HashScanAsync(ToInner(key), pattern, pageSize, cursor, pageOffset, flags);
123122

123+
public IAsyncEnumerable<RedisValue> HashScanNoValuesAsync(RedisKey key, RedisValue pattern, int pageSize, long cursor, int pageOffset, CommandFlags flags) =>
124+
Inner.HashScanNoValuesAsync(ToInner(key), pattern, pageSize, cursor, pageOffset, flags);
125+
124126
public Task<bool> HashSetAsync(RedisKey key, RedisValue hashField, RedisValue value, When when = When.Always, CommandFlags flags = CommandFlags.None) =>
125127
Inner.HashSetAsync(ToInner(key), hashField, value, when, flags);
126128

src/StackExchange.Redis/KeyspaceIsolation/KeyPrefixedDatabase.cs

+11-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public bool GeoAdd(RedisKey key, GeoEntry value, CommandFlags flags = CommandFla
3333
public bool GeoRemove(RedisKey key, RedisValue member, CommandFlags flags = CommandFlags.None) =>
3434
Inner.GeoRemove(ToInner(key), member, flags);
3535

36-
public double? GeoDistance(RedisKey key, RedisValue member1, RedisValue member2, GeoUnit unit = GeoUnit.Meters,CommandFlags flags = CommandFlags.None) =>
36+
public double? GeoDistance(RedisKey key, RedisValue member1, RedisValue member2, GeoUnit unit = GeoUnit.Meters, CommandFlags flags = CommandFlags.None) =>
3737
Inner.GeoDistance(ToInner(key), member1, member2, unit, flags);
3838

3939
public string?[] GeoHash(RedisKey key, RedisValue[] members, CommandFlags flags = CommandFlags.None) =>
@@ -48,7 +48,7 @@ public bool GeoRemove(RedisKey key, RedisValue member, CommandFlags flags = Comm
4848
public GeoPosition? GeoPosition(RedisKey key, RedisValue member, CommandFlags flags = CommandFlags.None) =>
4949
Inner.GeoPosition(ToInner(key), member, flags);
5050

51-
public GeoRadiusResult[] GeoRadius(RedisKey key, RedisValue member, double radius, GeoUnit unit = GeoUnit.Meters, int count = -1, Order? order = null,GeoRadiusOptions options = GeoRadiusOptions.Default, CommandFlags flags = CommandFlags.None) =>
51+
public GeoRadiusResult[] GeoRadius(RedisKey key, RedisValue member, double radius, GeoUnit unit = GeoUnit.Meters, int count = -1, Order? order = null, GeoRadiusOptions options = GeoRadiusOptions.Default, CommandFlags flags = CommandFlags.None) =>
5252
Inner.GeoRadius(ToInner(key), member, radius, unit, count, order, options, flags);
5353

5454
public GeoRadiusResult[] GeoRadius(RedisKey key, double longitude, double latitude, double radius, GeoUnit unit = GeoUnit.Meters, int count = -1, Order? order = null, GeoRadiusOptions options = GeoRadiusOptions.Default, CommandFlags flags = CommandFlags.None) =>
@@ -407,7 +407,7 @@ public long SortedSetAdd(RedisKey key, SortedSetEntry[] values, CommandFlags fla
407407
public long SortedSetAdd(RedisKey key, SortedSetEntry[] values, When when = When.Always, CommandFlags flags = CommandFlags.None) =>
408408
Inner.SortedSetAdd(ToInner(key), values, when, flags);
409409

410-
public long SortedSetAdd(RedisKey key, SortedSetEntry[] values,SortedSetWhen when = SortedSetWhen.Always, CommandFlags flags = CommandFlags.None) =>
410+
public long SortedSetAdd(RedisKey key, SortedSetEntry[] values, SortedSetWhen when = SortedSetWhen.Always, CommandFlags flags = CommandFlags.None) =>
411411
Inner.SortedSetAdd(ToInner(key), values, when, flags);
412412

413413
public bool SortedSetAdd(RedisKey key, RedisValue member, double score, CommandFlags flags) =>
@@ -510,7 +510,7 @@ public long SortedSetRemoveRangeByValue(RedisKey key, RedisValue min, RedisValue
510510
public double?[] SortedSetScores(RedisKey key, RedisValue[] members, CommandFlags flags = CommandFlags.None) =>
511511
Inner.SortedSetScores(ToInner(key), members, flags);
512512

513-
public long SortedSetUpdate(RedisKey key, SortedSetEntry[] values,SortedSetWhen when = SortedSetWhen.Always, CommandFlags flags = CommandFlags.None) =>
513+
public long SortedSetUpdate(RedisKey key, SortedSetEntry[] values, SortedSetWhen when = SortedSetWhen.Always, CommandFlags flags = CommandFlags.None) =>
514514
Inner.SortedSetUpdate(ToInner(key), values, when, flags);
515515

516516
public bool SortedSetUpdate(RedisKey key, RedisValue member, double score, SortedSetWhen when = SortedSetWhen.Always, CommandFlags flags = CommandFlags.None) =>
@@ -706,8 +706,14 @@ IEnumerable<HashEntry> IDatabase.HashScan(RedisKey key, RedisValue pattern, int
706706
IEnumerable<HashEntry> IDatabase.HashScan(RedisKey key, RedisValue pattern, int pageSize, long cursor, int pageOffset, CommandFlags flags)
707707
=> Inner.HashScan(ToInner(key), pattern, pageSize, cursor, pageOffset, flags);
708708

709+
IEnumerable<RedisValue> IDatabase.HashScanNoValues(RedisKey key, RedisValue pattern, int pageSize, CommandFlags flags)
710+
=> Inner.HashScanNoValues(ToInner(key), pattern, pageSize, flags);
711+
712+
IEnumerable<RedisValue> IDatabase.HashScanNoValues(RedisKey key, RedisValue pattern, int pageSize, long cursor, int pageOffset, CommandFlags flags)
713+
=> Inner.HashScanNoValues(ToInner(key), pattern, pageSize, cursor, pageOffset, flags);
714+
709715
IEnumerable<RedisValue> IDatabase.SetScan(RedisKey key, RedisValue pattern, int pageSize, CommandFlags flags)
710-
=> Inner.SetScan(ToInner(key), pattern, pageSize, flags);
716+
=> Inner.SetScan(ToInner(key), pattern, pageSize, flags);
711717

712718
IEnumerable<RedisValue> IDatabase.SetScan(RedisKey key, RedisValue pattern, int pageSize, long cursor, int pageOffset, CommandFlags flags)
713719
=> Inner.SetScan(ToInner(key), pattern, pageSize, cursor, pageOffset, flags);
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-

1+
StackExchange.Redis.IDatabase.HashScanNoValues(StackExchange.Redis.RedisKey key, StackExchange.Redis.RedisValue pattern = default(StackExchange.Redis.RedisValue), int pageSize = 250, long cursor = 0, int pageOffset = 0, StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> System.Collections.Generic.IEnumerable<StackExchange.Redis.RedisValue>!
2+
StackExchange.Redis.IDatabase.HashScanNoValues(StackExchange.Redis.RedisKey key, StackExchange.Redis.RedisValue pattern, int pageSize, StackExchange.Redis.CommandFlags flags) -> System.Collections.Generic.IEnumerable<StackExchange.Redis.RedisValue>!
3+
StackExchange.Redis.IDatabaseAsync.HashScanNoValuesAsync(StackExchange.Redis.RedisKey key, StackExchange.Redis.RedisValue pattern = default(StackExchange.Redis.RedisValue), int pageSize = 250, long cursor = 0, int pageOffset = 0, StackExchange.Redis.CommandFlags flags = StackExchange.Redis.CommandFlags.None) -> System.Collections.Generic.IAsyncEnumerable<StackExchange.Redis.RedisValue>!

0 commit comments

Comments
 (0)