Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
56ef34a
Creating ExecuteInTransaction function
shacharPash Nov 16, 2022
f1ebf4e
test cpmmit
shacharPash Nov 17, 2022
d6060d7
Add SerializedCommands & BloomSerializer
shacharPash Nov 17, 2022
92439ee
Creating ExecuteInTransaction function
shacharPash Nov 16, 2022
a93c134
test cpmmit
shacharPash Nov 17, 2022
1c6d286
Add SerializedCommands & BloomSerializer
shacharPash Nov 17, 2022
dedd93f
Fix SerializedCommand
shacharPash Nov 21, 2022
55bc897
Merge branch 'SupportTransactions' of github.com:redis/NRedisStack in…
shacharPash Nov 21, 2022
a6d2ec4
Add CmsCommandBuilder
shacharPash Nov 21, 2022
b524ada
Naming
shacharPash Nov 21, 2022
6929c05
Add CuckooCommndBuilder
shacharPash Nov 21, 2022
fdf6a89
Add TdigestCommndBuilder
shacharPash Nov 21, 2022
ca97a3f
Add TopKCommandBuilder
shacharPash Nov 22, 2022
c55a528
Add JsonCommandBuilder
shacharPash Nov 22, 2022
f2cc6a3
Add SearchCommandBuilder
shacharPash Nov 22, 2022
ba2d420
Fix Tests
shacharPash Nov 22, 2022
2855bcc
Add TimeSeriesCommandBuilder
shacharPash Nov 22, 2022
38c8bc8
Remove Unessesary using
shacharPash Nov 22, 2022
bac799c
Update Branch
shacharPash Nov 22, 2022
6b4100e
Connecting GraphCommands to the documentation of the interface
shacharPash Nov 22, 2022
9cc41d2
Add GraphCommandBuilder
shacharPash Nov 23, 2022
8899813
Update Version to 0.4.0
shacharPash Nov 29, 2022
ed7c24c
Writing README
shacharPash Nov 29, 2022
d5a9dec
update words to ignor
shacharPash Nov 29, 2022
52205e5
update words to ignore
shacharPash Nov 29, 2022
dfa282d
update words to ignore2
shacharPash Nov 29, 2022
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
5 changes: 5 additions & 0 deletions .github/wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ github
yml
Codecov
pre
OSS
Json
json
TimeSeries
NuGet
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,52 @@ This project builds on [StackExchange.Redis](https://github.com/StackExchange/St
## API

The complete documentation for Redis module commands can be found at the [Redis commands website](https://redis.io/commands/).

### Redis OSS commands
You can use Redis OSS commands in the same way as you use them in [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis).

### Modules Commands
Each module has a command class with its own commands.
The supported modules are: [Search](https://redis.io/commands/?group=search), [Json](https://redis.io/commands/?group=json), [Graph](https://redis.io/commands/?group=graph), [TimeSeries](https://redis.io/commands/?group=timeseries), [Bloom Filter](https://redis.io/commands/?group=bf), [Cuckoo Filter](https://redis.io/commands/?group=cf), [T-Digest](https://redis.io/commands/?group=tdigest), [Count-min Sketch](https://redis.io/commands/?group=cms) and [Top-K](https://redis.io/commands/?group=topk).

# Usage

First, you need to connect to Redis, exactly the same way you do it in [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis):
```csharp
using StackExchange.Redis;
...
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
```
Now you can create a variable from any type of module in the following way:
```csharp
IBloomCommands bf = db.BF();
ICuckooCommands cf = db.CF();
ICmsCommands cms = db.CMS();
IGraphCommands graph = db.GRAPH();
ITopKCommands topk = db.TOPK();
ITdigestCommands tdigest = db.TDIGEST();
ISearchCommands ft = db.FT();
IJsonCommands json = db.JSON();
ITimeSeriesCommands ts = db.TS();
```
Then, that variable will allow you to call all the commands of that module.
## Basic Example
Set a json object to Redis:
```csharp
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
IDatabase db = redis.GetDatabase();

IJsonCommands json = db.JSON();
var key = "myKey";
json.Set(key, "$", new Person() { Age = 35, Name = "Alice" });
```

------

### Author

NRedisStack is developed and maintained by [Redis Inc](https://redis.com). It can be found [here](
https://github.com/redis/NRedisStack), or downloaded from [NuGet](https://www.nuget.org/packages/NRedisStack).

[![Redis](./docs/logo-redis.png)](https://www.redis.com)

11 changes: 11 additions & 0 deletions src/NRedisStack/Auxiliary.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using NRedisStack.RedisStackCommands;
using StackExchange.Redis;

namespace NRedisStack
Expand All @@ -24,5 +25,15 @@ public static object[] AssembleNonNullArguments(params object?[] arguments)

return args.ToArray();
}

public static RedisResult Execute(this IDatabase db, SerializedCommand command)
{
return db.Execute(command.Command, command.Args);
}

public async static Task<RedisResult> ExecuteAsync(this IDatabase db, SerializedCommand command)
{
return await db.ExecuteAsync(command.Command, command.Args);
}
}
}
95 changes: 95 additions & 0 deletions src/NRedisStack/Bloom/BloomCommandBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using NRedisStack.Literals;
using NRedisStack.RedisStackCommands;
using StackExchange.Redis;
namespace NRedisStack
{

public static class BloomCommandBuilder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO comment the class too. Let's explain to users why this exists, why it's an issue.

{
public static SerializedCommand Add(RedisKey key, RedisValue item)
{
return new SerializedCommand(BF.ADD, key, item);
}

public static SerializedCommand Exists(RedisKey key, RedisValue item)
{
return new SerializedCommand(BF.EXISTS, key, item);
}

public static SerializedCommand Info(RedisKey key)
{
return new SerializedCommand(BF.INFO, key);
}

public static SerializedCommand Insert(RedisKey key, RedisValue[] items, int? capacity = null,
double? error = null, int? expansion = null,
bool nocreate = false, bool nonscaling = false)
{
if (items.Length < 1)
throw new ArgumentOutOfRangeException(nameof(items));

var args = BloomAux.BuildInsertArgs(key, items, capacity, error, expansion, nocreate, nonscaling);

return new SerializedCommand(BF.INSERT, args);
}

public static SerializedCommand LoadChunk(RedisKey key, long iterator, Byte[] data)
{
return new SerializedCommand(BF.LOADCHUNK, key, iterator, data);
}

public static SerializedCommand MAdd(RedisKey key, params RedisValue[] items)
{
if (items.Length < 1)
throw new ArgumentOutOfRangeException(nameof(items));

List<object> args = new List<object> { key };

foreach (var item in items)
{
args.Add(item);
}

return new SerializedCommand(BF.MADD, args);
}

public static SerializedCommand MExists(RedisKey key, RedisValue[] items)
{
if (items.Length < 1)
throw new ArgumentOutOfRangeException(nameof(items));

List<object> args = new List<object> { key };

foreach (var item in items)
{
args.Add(item);
}

return new SerializedCommand(BF.MEXISTS, args);

}

public static SerializedCommand Reserve(RedisKey key, double errorRate, long capacity,
int? expansion = null, bool nonscaling = false)
{
List<object> args = new List<object> { key, errorRate, capacity };

if (expansion != null)
{
args.Add(expansion);
}

if (nonscaling)
{
args.Add(BloomArgs.NONSCALING);
}

return new SerializedCommand(BF.RESERVE, args);
}

public static SerializedCommand ScanDump(RedisKey key, long iterator)
{
return new SerializedCommand(BF.SCANDUMP, key, iterator);
}
}
}
Loading