Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

added missing BitCount method to RedisClient #159

Merged
merged 1 commit into from
Jun 5, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ServiceStack.Redis/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static class Commands
public readonly static byte[] SetRange = "SETRANGE".ToUtf8Bytes();
public readonly static byte[] GetBit = "GETBIT".ToUtf8Bytes();
public readonly static byte[] SetBit = "SETBIT".ToUtf8Bytes();
public readonly static byte[] BitCount = "BITCOUNT".ToUtf8Bytes();

public readonly static byte[] RPush = "RPUSH".ToUtf8Bytes();
public readonly static byte[] LPush = "LPUSH".ToUtf8Bytes();
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceStack.Redis/Generic/RedisTypedTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public bool Commit()
queuedCommand.ProcessResult();
}
}
catch (RedisTransactionFailedException e)
catch (RedisTransactionFailedException)
{
rc = false;
}
Expand Down
8 changes: 8 additions & 0 deletions src/ServiceStack.Redis/RedisNativeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,14 @@ public long SetBit(string key, int offset, int value)
return SendExpectLong(Commands.SetBit, key.ToUtf8Bytes(), offset.ToUtf8Bytes(), value.ToUtf8Bytes());
}

public long BitCount(string key)
{
if (key == null)
throw new ArgumentNullException("key");

return SendExpectLong(Commands.BitCount, key.ToUtf8Bytes());
}

public string RandomKey()
{
return SendExpectData(Commands.RandomKey).FromUtf8Bytes();
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceStack.Redis/Transaction/RedisTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public bool Commit()
queuedCommand.ProcessResult();
}
}
catch (RedisTransactionFailedException e)
catch (RedisTransactionFailedException)
{
rc = false;
}
Expand Down
3 changes: 2 additions & 1 deletion tests/ServiceStack.Redis.Tests/Generic/RedisClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,13 @@ public void Can_StoreAll_RedisTypedClient()
}

[Test]
public void Can_SetBit_And_GetBit()
public void Can_SetBit_And_GetBit_And_BitCount()
{
const string key = "BitKey";
const int offset = 100;
Redis.SetBit(key, offset, 1);
Assert.AreEqual(1, Redis.GetBit(key,offset));
Assert.AreEqual(1, Redis.BitCount(key));
}

[Test, Explicit]
Expand Down