Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance code readability #241

Merged
merged 66 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
61011e3
Formatting and typos
gerzse Jan 25, 2024
07cdbcc
Include documentation in the build
gerzse Jan 25, 2024
9be88b9
Add support for BZMPOP (#233)
gerzse Jan 25, 2024
d5b8880
Skip new tests for Redis Cluster
gerzse Jan 25, 2024
132a224
Refactor and Change the List Collection to ICollection for better per…
nimanikoo Jan 26, 2024
b82ef2a
Change NameSpace to Scoped
nimanikoo Jan 26, 2024
5ffe8ad
Add Db to xml summary doc
nimanikoo Jan 26, 2024
bdd0b79
Fix Typo problem
nimanikoo Jan 26, 2024
cbfaa7b
Change constructor to primary constructor based on new feature in .net 8
nimanikoo Jan 26, 2024
9ceafb6
Fix Type for previously
nimanikoo Jan 26, 2024
ac81e90
refactor and Use Collection Expression for list initializing and chan…
nimanikoo Jan 26, 2024
24ad2aa
use primary constructor in CmsCommands.cs
nimanikoo Jan 26, 2024
d2f877a
use primary constructor in CmsCommands.cs
nimanikoo Jan 26, 2024
dbabb3a
Merge remote-tracking branch 'origin/Fixup' into Fixup
nimanikoo Jan 26, 2024
3cc5221
Refactor and change constructor to primary
nimanikoo Jan 26, 2024
fd45c00
Fix Typo and indent in CommandArgs.cs and IJsonCommands.cs
nimanikoo Jan 26, 2024
0713820
Fix Typo in ExampleTests.cs and IJsonCommandsAsync.cs and JsonCommand…
nimanikoo Jan 26, 2024
32d83d4
Use Linq and List Expression
nimanikoo Jan 26, 2024
bac3515
Refactor
nimanikoo Jan 26, 2024
794bbca
Improve the signatures of the new methods
gerzse Jan 29, 2024
0a8047a
Add test for BzmPop without keys
gerzse Jan 29, 2024
bbe2c4a
Add dedicated enum for MIN/MAX
gerzse Jan 29, 2024
117207c
Remove primary constructor syntax
gerzse Jan 29, 2024
04d0b9b
Separate concurrency groups for GitHub workflows
gerzse Jan 29, 2024
b8cd5d6
Fix indent in CuckooInformation.cs
nimanikoo Jan 29, 2024
bc36846
RollBack to original version of naming NumIncrbyAsync method in JsonC…
nimanikoo Jan 29, 2024
5bbf60f
Remove use of collection literals
gerzse Jan 29, 2024
bbb97d6
Increase multiplexer timeout in tests
gerzse Jan 29, 2024
579d1d8
Try to fix the linter workflow
gerzse Jan 29, 2024
e89743a
[Fix]
nimanikoo Jan 29, 2024
a656821
Use Linq Expression in JsonCommandBuilder.cs for reduce the amount of…
nimanikoo Jan 29, 2024
b9e1197
RollBack to original naming for NumIncrbyAsync
nimanikoo Jan 29, 2024
bcdda60
RollBack to original naming
nimanikoo Jan 29, 2024
b6ca7fb
Refactored C# code using collection expressions and the :? operator f…
nimanikoo Jan 29, 2024
f478df3
Used Inverted If technique and removed redundant else for code optimi…
nimanikoo Jan 29, 2024
12c9c87
Used Invert If technique and removed redundant else for code optimiza…
nimanikoo Jan 29, 2024
bce49c6
Sync Namespace and use scoped namespace and use operator instead if
nimanikoo Jan 29, 2024
94c133c
ConvertMultiBulkToObject for handle multi-bulk based on your todo in …
nimanikoo Jan 29, 2024
481b7e9
Optimized codebase by removing redundant elements for improved effici…
nimanikoo Jan 29, 2024
20d215c
Merge branch 'pr/gerzse/240' into pr/nimanikoo/241
shacharPash Jan 30, 2024
6f6c147
Sort Modifier and inverting if in Auxiliary.cs
nimanikoo Feb 1, 2024
2016629
Sync NameSpaces also you can use ITestOutputHelper for output your te…
nimanikoo Feb 1, 2024
66bf07c
Merge branch 'master' into pr/nimanikoo/241
shacharPash Feb 5, 2024
1aed66b
Merge remote-tracking branch 'origin/master' into pr/nimanikoo/241
shacharPash Feb 13, 2024
97d01aa
fix CoreCommand file
shacharPash Feb 14, 2024
8308110
Fix bug for build Doc Tests and return to orginal version
nimanikoo Feb 25, 2024
c88f137
Merge branch 'master' into pr/nimanikoo/241
shacharPash Feb 25, 2024
389bcf6
fix error
shacharPash Feb 25, 2024
ecf7ae0
Roleback ' List<object> args = [key];'
nimanikoo Mar 3, 2024
a9ad102
Merge branch 'master' into Fixup
nimanikoo Mar 6, 2024
6266db5
Merge branch 'master' into pr/nimanikoo/241
shacharPash Mar 7, 2024
30ff30b
fix compilation error
shacharPash Mar 7, 2024
a3eb232
format
shacharPash Mar 7, 2024
15eaca6
Merge branch 'master' into Fixup
nimanikoo Mar 12, 2024
d35f866
Fix Indent and Solve Problem of old .net version with feature primary…
nimanikoo Mar 12, 2024
c9f3cac
Merge remote-tracking branch 'origin/Fixup' into Fixup
nimanikoo Mar 12, 2024
5817619
Fix Issues for compiler error in .net 8 error CS8652: The feature 'co…
nimanikoo Mar 12, 2024
496fcc3
Fix Compiler Error in JsonCommandsAsync.cs and JsonCommands.cs for Er…
nimanikoo Mar 13, 2024
56ca7ae
return ExampleTests's ctor
shacharPash Mar 14, 2024
1927c87
Fix typo for TransactionsTests.cs in method naming TestModulesTransac…
nimanikoo Mar 14, 2024
e1eacb3
Fix Typo and namespace also Set Private Access Modifier RedisFixture.…
nimanikoo Mar 14, 2024
d75b17b
Fix Typo and set const for readonly key PipelineTests.cs
nimanikoo Mar 14, 2024
15e3e44
Fix Typo and Change Namespace to scoped AbstractNRedisStackTest.cs an…
nimanikoo Mar 14, 2024
5bb7d65
Return to Collection Initializer for collections in ExampleTests.cs
nimanikoo Mar 14, 2024
ef9ddaa
Return `ExecuteAsync` method in Auxiliary.cs to original version for …
nimanikoo Mar 18, 2024
4159b23
Revert ToString() in code snippets
gerzse Mar 19, 2024
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
104 changes: 47 additions & 57 deletions src/NRedisStack/Bloom/BloomAux.cs
Original file line number Diff line number Diff line change
@@ -1,74 +1,64 @@
using NRedisStack.Bloom.Literals;
using StackExchange.Redis;

namespace NRedisStack
namespace NRedisStack;

public static class BloomAux
{
public static class BloomAux
public static List<object> BuildInsertArgs(RedisKey key, IEnumerable<RedisValue> items, int? capacity,
double? error, int? expansion, bool nocreate, bool nonscaling)
{
public static List<object> BuildInsertArgs(RedisKey key, RedisValue[] items, int? capacity,
double? error, int? expansion, bool nocreate, bool nonscaling)
{
var args = new List<object> { key };
args.AddCapacity(capacity);
args.AddError(error);
args.AddExpansion(expansion);
args.AddNoCreate(nocreate);
args.AddNoScaling(nonscaling);
args.AddItems(items);
var args = new List<object> { key };
args.AddCapacity(capacity);
args.AddError(error);
args.AddExpansion(expansion);
args.AddNoCreate(nocreate);
args.AddNoScaling(nonscaling);
args.AddItems(items);

return args;
}
return args;
}

private static void AddItems(this List<object> args, RedisValue[] items)
{
args.Add(BloomArgs.ITEMS);
foreach (var item in items)
{
args.Add(item);
}
}
private static void AddItems(this List<object> args, IEnumerable<RedisValue> items)
{
args.Add(BloomArgs.ITEMS);
args.AddRange(items.Cast<object>());
}

private static void AddNoScaling(this List<object> args, bool nonscaling)
private static void AddNoScaling(this ICollection<object> args, bool nonScaling)
{
if (nonScaling)
{
if (nonscaling)
{
args.Add(BloomArgs.NONSCALING);
}
args.Add(BloomArgs.NONSCALING);
}
}

private static void AddNoCreate(this List<object> args, bool nocreate)
private static void AddNoCreate(this ICollection<object> args, bool nocreate)
{
if (nocreate)
{
if (nocreate)
{
args.Add(BloomArgs.NOCREATE);
}
args.Add(BloomArgs.NOCREATE);
}
}

private static void AddExpansion(this List<object> args, int? expansion)
{
if (expansion != null)
{
args.Add(BloomArgs.EXPANSION);
args.Add(expansion);
}
}
private static void AddExpansion(this ICollection<object> args, int? expansion)
{
if (expansion == null) return;
args.Add(BloomArgs.EXPANSION);
args.Add(expansion);
}

private static void AddError(this List<object> args, double? error)
{
if (error != null)
{
args.Add(BloomArgs.ERROR);
args.Add(error);
}
}
private static void AddError(this ICollection<object> args, double? error)
{
if (error == null) return;
args.Add(BloomArgs.ERROR);
args.Add(error);
}

private static void AddCapacity(this List<object> args, int? capacity)
{
if (capacity != null)
{
args.Add(BloomArgs.CAPACITY);
args.Add(capacity);
}
}
private static void AddCapacity(this ICollection<object> args, int? capacity)
{
if (capacity == null) return;
args.Add(BloomArgs.CAPACITY);
args.Add(capacity);
}
}
}
134 changes: 62 additions & 72 deletions src/NRedisStack/Bloom/BloomCommandBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,100 +1,90 @@
using NRedisStack.RedisStackCommands;
using StackExchange.Redis;
using NRedisStack.Bloom.Literals;
namespace NRedisStack
{
namespace NRedisStack;

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

public static SerializedCommand Card(RedisKey key)
{
return new SerializedCommand(BF.CARD, key);
}
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 Card(RedisKey key)
{
return new SerializedCommand(BF.CARD, key);
}

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

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));
public static SerializedCommand Info(RedisKey key)
{
return new SerializedCommand(BF.INFO, key);
}

var args = BloomAux.BuildInsertArgs(key, items, capacity, error, expansion, nocreate, nonscaling);
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));

return new SerializedCommand(BF.INSERT, args);
}
var args = BloomAux.BuildInsertArgs(key, items, capacity, error, expansion, nocreate, nonscaling);

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

public static SerializedCommand MAdd(RedisKey key, params RedisValue[] items)
{
if (items.Length < 1)
throw new ArgumentOutOfRangeException(nameof(items));
public static SerializedCommand LoadChunk(RedisKey key, long iterator, Byte[] data)
{
return new SerializedCommand(BF.LOADCHUNK, key, iterator, data);
}

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

foreach (var item in items)
{
args.Add(item);
}
List<object> args = [key];
args.AddRange(items.Cast<object>());

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

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

List<object> args = new List<object> { key };
List<object> args = [key];
args.AddRange(items.Cast<object>());

foreach (var item in items)
{
args.Add(item);
}
return new SerializedCommand(BF.MEXISTS, args);

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 };

public static SerializedCommand Reserve(RedisKey key, double errorRate, long capacity,
int? expansion = null, bool nonscaling = false)
if (expansion != null)
{
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);
args.Add(expansion);
}

public static SerializedCommand ScanDump(RedisKey key, long iterator)
if (nonscaling)
{
return new SerializedCommand(BF.SCANDUMP, key, iterator);
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