Skip to content

Commit

Permalink
continue BITFIELD #186
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed May 19, 2024
1 parent bbd364c commit 6832e8b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/FreeRedis/IRedisClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public interface IRedisClient
long XTrim(string key, long count);
long Append<T>(string key, T value);
long BitCount(string key, long start, long end);
long[] BitField(string key, params BitFieldOperationArgument[] operations);
long[] BitField(string key, params BitFieldAction[] actions);
long BitOp(BitOpOperation operation, string destkey, params string[] keys);
long BitPos(string key, bool bit, long? start = null, long? end = null);
long Decr(string key);
Expand Down Expand Up @@ -684,7 +684,7 @@ public interface IRedisClient
Task<long> XTrimAsync(string key, long count);
Task<long> AppendAsync<T>(string key, T value);
Task<long> BitCountAsync(string key, long start, long end);
Task<long[]> BitFieldAsync(string key, params BitFieldOperationArgument[] operations);
Task<long[]> BitFieldAsync(string key, params BitFieldAction[] actions);
Task<long> BitOpAsync(BitOpOperation operation, string destkey, params string[] keys);
Task<long> BitPosAsync(string key, bool bit, long? start = null, long? end = null);
Task<long> DecrAsync(string key);
Expand Down
2 changes: 1 addition & 1 deletion src/FreeRedis/RedisClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public class ScanResult<T>
public readonly long length;
public ScanResult(long cursor, T[] items) { this.cursor = cursor; this.items = items; this.length = items.LongLength; }
}
public class BitFieldOperationArgument
public class BitFieldAction
{
public BitFieldOperation operation;
public object[] arguments;
Expand Down
16 changes: 8 additions & 8 deletions src/FreeRedis/RedisClient/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ partial class RedisClient
/// <returns>The number of set bits in the string. Non-existent keys are treated as empty strings and will return zero.</returns>
public Task<long> BitCountAsync(string key, long start, long end) => CallAsync("BITCOUNT".InputKey(key, start, end), rt => rt.ThrowOrValue<long>());

public Task<long[]> BitFieldAsync(string key, params BitFieldOperationArgument[] operations)
public Task<long[]> BitFieldAsync(string key, params BitFieldAction[] actions)
{
if (operations?.Any() != true) return null;
return CallAsync(GetBitFieldCommandPacket(key, operations), rt => rt.ThrowOrValue<long[]>());
if (actions?.Any() != true) return null;
return CallAsync(GetBitFieldCommandPacket(key, actions), rt => rt.ThrowOrValue<long[]>());
}

/// <summary>
Expand Down Expand Up @@ -737,15 +737,15 @@ public Task<string> SetAsync<T>(string key, T value, TimeSpan timeout, bool keep
/// <returns>The number of set bits in the string. Non-existent keys are treated as empty strings and will return zero.</returns>
public long BitCount(string key, long start, long end) => Call("BITCOUNT".InputKey(key, start, end), rt => rt.ThrowOrValue<long>());

public long[] BitField(string key, params BitFieldOperationArgument[] operations)
public long[] BitField(string key, params BitFieldAction[] actions)
{
if (operations?.Any() != true) return null;
return Call(GetBitFieldCommandPacket(key, operations), rt => rt.ThrowOrValue<long[]>());
if (actions?.Any() != true) return null;
return Call(GetBitFieldCommandPacket(key, actions), rt => rt.ThrowOrValue<long[]>());
}
CommandPacket GetBitFieldCommandPacket(string key, BitFieldOperationArgument[] operations)
CommandPacket GetBitFieldCommandPacket(string key, BitFieldAction[] actions)
{
var cmd = "BITFIELD".InputKey(key);
foreach (var opt in operations)
foreach (var opt in actions)
{
switch (opt.operation)
{
Expand Down

0 comments on commit 6832e8b

Please sign in to comment.