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

Commit 7183955

Browse files
committed
Update README.md
1 parent 7db48fb commit 7183955

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,56 @@ follow [@servicestack](http://twitter.com/servicestack) for updates.
33

44
# C#/.NET Client for Redis
55

6+
### New HyperLog API
7+
8+
The development branch of Redis server (available when v3.0 is released) includes an ingenious algorithm to approximate the unique elements in a set with maximum space and time efficiency. For details about how it works see Redis's creator Salvatore's blog who [explains it in great detail](http://antirez.com/news/75). Essentially it lets you maintain an efficient way to count and merge unique elements in a set without having to store its elements.
9+
A Simple example of it in action:
10+
11+
```csharp
12+
redis.AddToHyperLog("set1", "a", "b", "c");
13+
redis.AddToHyperLog("set1", "c", "d");
14+
var count = redis.CountHyperLog("set1"); //4
15+
16+
redis.AddToHyperLog("set2", "c", "d", "e", "f");
17+
18+
redis.MergeHyperLogs("mergedset", "set1", "set2");
19+
20+
var mergeCount = redis.CountHyperLog("mergedset"); //6
21+
```
22+
23+
### New Scan APIs Added
24+
25+
Redis v2.8 introduced a beautiful new [SCAN](http://redis.io/commands/scan) operation that provides an optimal strategy for traversing a redis instance entire keyset in managable-size chunks utilizing only a client-side cursor and without introducing any server state. It's a higher performance alternative and should be used instead of [KEYS](http://redis.io/commands/keys) in application code. SCAN and its related operations for traversing members of Sets, Sorted Sets and Hashes are now available in the Redis Client in the following API's:
26+
27+
```csharp
28+
public interface IRedisClient
29+
{
30+
...
31+
IEnumerable<string> ScanAllKeys(string pattern = null, int pageSize = 1000);
32+
IEnumerable<string> ScanAllSetItems(string setId, string pattern = null, int pageSize = 1000);
33+
IEnumerable<KeyValuePair<string, double>> ScanAllSortedSetItems(string setId, string pattern = null, int pageSize = 1000);
34+
IEnumerable<KeyValuePair<string, string>> ScanAllHashEntries(string hashId, string pattern = null, int pageSize = 1000);
35+
}
36+
37+
//Low-level API
38+
public interface IRedisNativeClient
39+
{
40+
...
41+
ScanResult Scan(ulong cursor, int count = 10, string match = null);
42+
ScanResult SScan(string setId, ulong cursor, int count = 10, string match = null);
43+
ScanResult ZScan(string setId, ulong cursor, int count = 10, string match = null);
44+
ScanResult HScan(string hashId, ulong cursor, int count = 10, string match = null);
45+
}
46+
```
47+
48+
The `IRedisClient` provides a higher-level API that abstracts away the client cursor to expose a lazy Enumerable sequence to provide an optimal way to stream scanned results that integrates nicely with LINQ, e.g:
49+
50+
```csharp
51+
var scanUsers = Redis.ScanAllKeys("urn:User:*");
52+
var sampleUsers = scanUsers.Take(10000).ToList(); //Stop after retrieving 10000 user keys
53+
```
54+
55+
656
### New IRedisClient LUA API's
757

858
The `IRedisClient` API's for [redis server-side LUA support](http://redis.io/commands/eval) have been re-factored into the more user-friendly API's below:

0 commit comments

Comments
 (0)