Skip to content

Commit 9d404cd

Browse files
committed
Add Command Literal Classes
1 parent cdf7dd7 commit 9d404cd

File tree

12 files changed

+136
-42
lines changed

12 files changed

+136
-42
lines changed
Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using NRedisStack.Core.Literals;
12
using StackExchange.Redis;
23
namespace NRedisStack.Core
34
{
@@ -13,22 +14,12 @@ public BloomCommands(IDatabase db)
1314

1415
public RedisResult Add(RedisKey key, string item)
1516
{
16-
return _db.Execute("BF.ADD", key, item);
17+
return _db.Execute(BF.ADD, key, item);
1718
}
1819
public RedisResult Exists(RedisKey key, string item)
1920
{
20-
return _db.Execute("BF.EXISTS", key, item);
21+
return _db.Execute(BF.EXISTS, key, item);
2122
}
22-
/*public static string ADD => "BF.ADD";
23-
public static string EXISTS => "BF.EXISTS";
24-
public static string INFO => "BF.INFO";
25-
public static string INSERT => "BF.INSERT";
26-
public static string LOADCHUNK => "BF.LOADCHUNK";
27-
public static string MADD => "BF.MADD";
28-
public static string MEXISTS => "BF.MEXISTS";
29-
public static string RESERVE => "BF.RESERVE";
30-
public static string SCANDUMP => "BF.SCANDUMP";*/
31-
}
32-
3323

24+
}
3425
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace NRedisStack.Core.Literals
2+
{
3+
internal class BloomArgs
4+
{
5+
6+
}
7+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace NRedisStack.Core.Literals
2+
{
3+
internal class BF
4+
{
5+
public static string ADD => "BF.ADD";
6+
public static string EXISTS => "BF.EXISTS";
7+
public static string INFO => "BF.INFO";
8+
public static string INSERT => "BF.INSERT";
9+
public static string LOADCHUNK => "BF.LOADCHUNK";
10+
public static string MADD => "BF.MADD";
11+
public static string MEXISTS => "BF.MEXISTS";
12+
public static string RESERVE => "BF.RESERVE";
13+
public static string SCANDUMP => "BF.SCANDUMP";
14+
}
15+
}

src/NRedisStack.Core/Json/JsonCommands.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using StackExchange.Redis;
1+
using NRedisStack.Core.Literals;
2+
using StackExchange.Redis;
23
using System.Text.Json;
34
using System.Text.Json.Serialization;
45

@@ -26,11 +27,11 @@ public RedisResult Set(RedisKey key, string path, string json, When when = When.
2627
switch (when)
2728
{
2829
case When.Exists:
29-
return _db.Execute("JSON.SET", key, path, json, "XX");
30+
return _db.Execute(JSON.SET, key, path, json, "XX");
3031
case When.NotExists:
31-
return _db.Execute("JSON.SET", key, path, json, "NX");
32+
return _db.Execute(JSON.SET, key, path, json, "NX");
3233
default:
33-
return _db.Execute("JSON.SET", key, path, json);
34+
return _db.Execute(JSON.SET, key, path, json);
3435
}
3536
}
3637

@@ -41,26 +42,26 @@ public RedisResult Get(RedisKey key, string indent = "",
4142
subcommands.Add(key);
4243
if (indent != "")
4344
{
44-
subcommands.Add("INDENT");
45+
subcommands.Add(JsonArgs.INDENT);
4546
subcommands.Add(indent);
4647
}
4748

4849
if (newLine != "")
4950
{
50-
subcommands.Add("NEWLINE");
51+
subcommands.Add(JsonArgs.NEWLINE);
5152
subcommands.Add(newLine);
5253
}
5354

5455
if (space != "")
5556
{
56-
subcommands.Add("SPACE");
57+
subcommands.Add(JsonArgs.SPACE);
5758
subcommands.Add(space);
5859
}
5960

6061
if (path != "")
6162
{
6263
subcommands.Add(path);
6364
}
64-
return _db.Execute("JSON.GET", subcommands.ToArray());
65+
return _db.Execute(JSON.GET, subcommands.ToArray());
6566
}
6667
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace NRedisStack.Core.Literals
2+
{
3+
internal class JsonArgs
4+
{
5+
public static string INDENT => "INDENT";
6+
public static string NEWLINE => "NEWLINE";
7+
public static string SPACE => "SPACE";
8+
9+
}
10+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace NRedisStack.Core.Literals
2+
{
3+
internal class JSON
4+
{
5+
public static string ARRAPPEND => "JSON.ARRAPPEND";
6+
public static string ARRINDEX => "JSON.ARRINDEX";
7+
public static string ARRINSERT => "JSON.ARRINSERT";
8+
public static string ARRLEN => "JSON.ARRLEN";
9+
public static string ARRPOP => "JSON.ARRPOP";
10+
public static string ARRTRIM => "JSON.ARRTRIM";
11+
public static string CLEAR => "JSON.CLEAR";
12+
public static string DEBUG => "JSON.DEBUG";
13+
public static string DEBUG_HELP => "JSON.DEBUG HELP";
14+
public static string DEBUG_MEMORY => "JSON.DEBUG MEMORY";
15+
public static string DEL => "JSON.DEL";
16+
public static string FORGET => "JSON.FORGET";
17+
public static string GET => "JSON.GET";
18+
public static string MGET => "JSON.MGET";
19+
public static string NUMINCRBY => "JSON.NUMINCRBY";
20+
public static string NUMMULTBY => "JSON.NUMMULTBY";
21+
public static string OBJKEYS => "JSON.OBJKEYS";
22+
public static string OBJLEN => "JSON.OBJLEN";
23+
public static string RESP => "JSON.RESP";
24+
public static string SET => "JSON.SET";
25+
public static string STRAPPEND => "JSON.STRAPPEND";
26+
public static string STRLEN => "JSON.STRLEN";
27+
public static string TOGGLE => "JSON.TOGGLE";
28+
public static string TYPE => "JSON.TYPE";
29+
}
30+
}

src/NRedisStack.Core/ModulPrefixes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace NRedisStack.Core.RedisStackCommands
44
{
55
public static class ModulPrefixes
66
{
7+
// Every call, new instance is being created. need to be fix
78
static public BloomCommands BF(this IDatabase db)
89
{
910
return new BloomCommands(db);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace NRedisStack.Core.Literals
2+
{
3+
internal class SearchArgs
4+
{
5+
6+
}
7+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
namespace NRedisStack.Core.Literals
2+
{
3+
internal class FT
4+
{
5+
public static string _LIST => "FT._LIST";
6+
public static string AGGREGATE => "FT.AGGREGATE";
7+
public static string ALIASADD => "FT.ALIASADD";
8+
public static string ALIASDEL => "FT.ALIASDEL";
9+
public static string ALIASUPDATE => "FT.ALIASUPDATE";
10+
public static string ALTER => "FT.ALTER";
11+
public static string CONFIG_GET => "FT.CONFIG GET";
12+
public static string CONFIG_HELP => "FT.CONFIG HELP";
13+
public static string CONFIG_SET => "FT.CONFIG SET";
14+
public static string CREATE => "FT.CREATE";
15+
public static string CURSOR_DEL => "FT.CURSOR DEL";
16+
public static string CURSOR_READ => "FT.CURSOR READ";
17+
public static string DICTADD => "FT.DICTADD";
18+
public static string DICTDEL => "FT.DICTDEL";
19+
public static string DICTDUMP => "FT.DICTDUMP";
20+
public static string DROPINDEX => "FT.DROPINDEX";
21+
public static string EXPLAIN => "FT.EXPLAIN";
22+
public static string EXPLAINCLI => "FT.EXPLAINCLI";
23+
public static string INFO => "FT.INFO";
24+
public static string PROFILE => "FT.PROFILE";
25+
public static string SEARCH => "FT.SEARCH";
26+
public static string SPELLCHECK => "FT.SPELLCHECK";
27+
public static string SYNDUMP => "FT.SYNDUMP";
28+
public static string SYNUPDATE => "FT.SYNUPDATE";
29+
public static string TAGVALS => "FT.TAGVALS";
30+
}
31+
}

src/NRedisStack.Core/Search/SearchCommands.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using NRedisStack.Core.Literals;
12
using StackExchange.Redis;
23
namespace NRedisStack.Core
34
{
@@ -8,9 +9,9 @@ public SearchCommands(IDatabase db)
89
{
910
_db = db;
1011
}
11-
public RedisResult FtInfo(string index)
12+
public RedisResult Info(string index)
1213
{
13-
return _db.Execute("FT.INFO", index);
14+
return _db.Execute(FT.INFO, index);
1415
}
1516
}
1617
}

0 commit comments

Comments
 (0)