Skip to content

Commit

Permalink
Merge pull request #288 from catcherwong/master
Browse files Browse the repository at this point in the history
RedisHelper support ZPopMax/ZPopMin
  • Loading branch information
2881099 authored Apr 13, 2020
2 parents d893516 + e0031ac commit e46e87b
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/RedisHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,42 @@ public static long ZRemRangeByLex(string key, string min, string max) =>
/// <returns></returns>
public static long ZLexCount(string key, string min, string max) =>
Instance.ZLexCount(key, min, max);

/// <summary>
/// [redis-server 5.0.0] 删除并返回有序集合key中的最多count个具有最高得分的成员。如未指定,count的默认值为1。指定一个大于有序集合的基数的count不会产生错误。 当返回多个元素时候,得分最高的元素将是第一个元素,然后是分数较低的元素。
/// </summary>
/// <param name="key">不含prefix前辍</param>
/// <param name="count">数量</param>
/// <returns></returns>
public static (string member, decimal score)[] ZPopMax(string key, long count) =>
Instance.ZPopMax(key, count);

/// <summary>
/// [redis-server 5.0.0] 删除并返回有序集合key中的最多count个具有最高得分的成员。如未指定,count的默认值为1。指定一个大于有序集合的基数的count不会产生错误。 当返回多个元素时候,得分最高的元素将是第一个元素,然后是分数较低的元素。
/// </summary>
/// <param name="key">不含prefix前辍</param>
/// <param name="count">数量</param>
/// <returns></returns>
public static (T member, decimal score)[] ZPopMax<T>(string key, long count) =>
Instance.ZPopMax<T>(key, count);

/// <summary>
/// [redis-server 5.0.0] 删除并返回有序集合key中的最多count个具有最低得分的成员。如未指定,count的默认值为1。指定一个大于有序集合的基数的count不会产生错误。 当返回多个元素时候,得分最低的元素将是第一个元素,然后是分数较高的元素。
/// </summary>
/// <param name="key">不含prefix前辍</param>
/// <param name="count">数量</param>
/// <returns></returns>
public static (string member, decimal score)[] ZPopMin(string key, long count) =>
Instance.ZPopMin(key, count);

/// <summary>
/// [redis-server 5.0.0] 删除并返回有序集合key中的最多count个具有最低得分的成员。如未指定,count的默认值为1。指定一个大于有序集合的基数的count不会产生错误。 当返回多个元素时候,得分最低的元素将是第一个元素,然后是分数较高的元素。
/// </summary>
/// <param name="key">不含prefix前辍</param>
/// <param name="count">数量</param>
/// <returns></returns>
public static (T member, decimal score)[] ZPopMin<T>(string key, long count) =>
Instance.ZPopMin<T>(key, count);
#endregion

#region Set
Expand Down Expand Up @@ -1890,7 +1926,7 @@ public static (T member, decimal dist, decimal longitude, decimal latitude)[] Ge
Instance.GeoRadiusByMemberWithDistAndCoord<T>(key, member, radius, unit, count, sorting);
#endregion

/// <summary>
/// <summary>
/// 开启分布式锁,若超时返回null
/// </summary>
/// <param name="name">锁名称</param>
Expand Down
36 changes: 36 additions & 0 deletions src/RedisHelperAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,42 @@ public static Task<long> ZLexCountAsync(string key, string min, string max) =>
/// <returns></returns>
public static Task<RedisScan<(string field, T value)>> HScanAsync<T>(string key, long cursor, string pattern = null, long? count = null) =>
Instance.HScanAsync<T>(key, cursor, pattern, count);

/// <summary>
/// [redis-server 5.0.0] 删除并返回有序集合key中的最多count个具有最高得分的成员。如未指定,count的默认值为1。指定一个大于有序集合的基数的count不会产生错误。 当返回多个元素时候,得分最高的元素将是第一个元素,然后是分数较低的元素。
/// </summary>
/// <param name="key">不含prefix前辍</param>
/// <param name="count">数量</param>
/// <returns></returns>
public static Task<(string member, decimal score)[]> ZPopMaxAsync(string key, long count) =>
Instance.ZPopMaxAsync(key, count);

/// <summary>
/// [redis-server 5.0.0] 删除并返回有序集合key中的最多count个具有最高得分的成员。如未指定,count的默认值为1。指定一个大于有序集合的基数的count不会产生错误。 当返回多个元素时候,得分最高的元素将是第一个元素,然后是分数较低的元素。
/// </summary>
/// <param name="key">不含prefix前辍</param>
/// <param name="count">数量</param>
/// <returns></returns>
public static Task<(T member, decimal score)[]> ZPopMaxAsync<T>(string key, long count) =>
Instance.ZPopMaxAsync<T>(key, count);

/// <summary>
/// [redis-server 5.0.0] 删除并返回有序集合key中的最多count个具有最低得分的成员。如未指定,count的默认值为1。指定一个大于有序集合的基数的count不会产生错误。 当返回多个元素时候,得分最低的元素将是第一个元素,然后是分数较高的元素。
/// </summary>
/// <param name="key">不含prefix前辍</param>
/// <param name="count">数量</param>
/// <returns></returns>
public static Task<(string member, decimal score)[]> ZPopMinAsync(string key, long count) =>
Instance.ZPopMinAsync(key, count);

/// <summary>
/// [redis-server 5.0.0] 删除并返回有序集合key中的最多count个具有最低得分的成员。如未指定,count的默认值为1。指定一个大于有序集合的基数的count不会产生错误。 当返回多个元素时候,得分最低的元素将是第一个元素,然后是分数较高的元素。
/// </summary>
/// <param name="key">不含prefix前辍</param>
/// <param name="count">数量</param>
/// <returns></returns>
public static Task<(T member, decimal score)[]> ZPopMinAsync<T>(string key, long count) =>
Instance.ZPopMinAsync<T>(key, count);
#endregion

#region String
Expand Down

0 comments on commit e46e87b

Please sign in to comment.