Skip to content
New issue

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

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

Already on GitHub? # to your account

Pipeline support #50

Merged
merged 25 commits into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion src/NRedisStack/Auxiliary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ 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)
public async static Task<RedisResult> ExecuteAsync(this IDatabaseAsync db, SerializedCommand command)
{
return await db.ExecuteAsync(command.Command, command.Args);
}
Expand Down
68 changes: 2 additions & 66 deletions src/NRedisStack/Bloom/BloomCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace NRedisStack
{

public class BloomCommands : IBloomCommands
public class BloomCommands : BloomCommandsAsync, IBloomCommands
{
IDatabase _db;
public BloomCommands(IDatabase db)
public BloomCommands(IDatabase db) : base(db)
{
_db = db;
}
Expand All @@ -17,49 +17,24 @@ public bool Add(RedisKey key, RedisValue item)
return _db.Execute(BloomCommandBuilder.Add(key, item)).ToString() == "1";
}

/// <inheritdoc/>
public async Task<bool> AddAsync(RedisKey key, RedisValue item)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.Add(key, item))).ToString() == "1";
}

/// <inheritdoc/>
public long Card(RedisKey key)
{
return _db.Execute(BloomCommandBuilder.Card(key)).ToLong();
}

/// <inheritdoc/>
public async Task<long> CardAsync(RedisKey key)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.Card(key))).ToLong();
}

/// <inheritdoc/>
public bool Exists(RedisKey key, RedisValue item)
{
return _db.Execute(BloomCommandBuilder.Exists(key, item)).ToString() == "1";
}

/// <inheritdoc/>
public async Task<bool> ExistsAsync(RedisKey key, RedisValue item)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.Exists(key, item))).ToString() == "1";
}

/// <inheritdoc/>
public BloomInformation Info(RedisKey key)
{
return _db.Execute(BloomCommandBuilder.Info(key)).ToBloomInfo();
}

/// <inheritdoc/>
public async Task<BloomInformation> InfoAsync(RedisKey key)
{
var info = (await _db.ExecuteAsync(BloomCommandBuilder.Info(key)));
return info.ToBloomInfo();
}

/// <inheritdoc/>
public bool[] Insert(RedisKey key, RedisValue[] items, int? capacity = null,
double? error = null, int? expansion = null,
Expand All @@ -68,74 +43,35 @@ public bool[] Insert(RedisKey key, RedisValue[] items, int? capacity = null,
return _db.Execute(BloomCommandBuilder.Insert(key, items, capacity, error, expansion, nocreate, nonscaling)).ToBooleanArray();
}

/// <inheritdoc/>
public async Task<bool[]> InsertAsync(RedisKey key, RedisValue[] items, int? capacity = null,
double? error = null, int? expansion = null,
bool nocreate = false, bool nonscaling = false)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.Insert(key, items, capacity, error, expansion, nocreate, nonscaling))).ToBooleanArray();
}

/// <inheritdoc/>
public bool LoadChunk(RedisKey key, long iterator, Byte[] data)
{
return _db.Execute(BloomCommandBuilder.LoadChunk(key, iterator, data)).OKtoBoolean();
}

/// <inheritdoc/>
public async Task<bool> LoadChunkAsync(RedisKey key, long iterator, Byte[] data)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.LoadChunk(key, iterator, data))).OKtoBoolean();
}

/// <inheritdoc/>
public bool[] MAdd(RedisKey key, params RedisValue[] items)
{
return _db.Execute(BloomCommandBuilder.MAdd(key, items)).ToBooleanArray();
}

/// <inheritdoc/>
public async Task<bool[]> MAddAsync(RedisKey key, params RedisValue[] items)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.MAdd(key, items))).ToBooleanArray();
}

/// <inheritdoc/>
public bool[] MExists(RedisKey key, RedisValue[] items)
{
return _db.Execute(BloomCommandBuilder.MExists(key, items)).ToBooleanArray();
}

/// <inheritdoc/>
public async Task<bool[]> MExistsAsync(RedisKey key, RedisValue[] items)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.MExists(key, items))).ToBooleanArray();
}

/// <inheritdoc/>
public bool Reserve(RedisKey key, double errorRate, long capacity,
int? expansion = null, bool nonscaling = false)
{
return _db.Execute(BloomCommandBuilder.Reserve(key, errorRate, capacity, expansion, nonscaling)).OKtoBoolean();
}

/// <inheritdoc/>
public async Task<bool> ReserveAsync(RedisKey key, double errorRate, long capacity,
int? expansion = null, bool nonscaling = false)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.Reserve(key, errorRate, capacity, expansion, nonscaling))).OKtoBoolean();
}

/// <inheritdoc/>
public Tuple<long, Byte[]> ScanDump(RedisKey key, long iterator)
{
return _db.Execute(BloomCommandBuilder.ScanDump(key, iterator)).ToScanDumpTuple();
}

/// <inheritdoc/>
public async Task<Tuple<long, Byte[]>> ScanDumpAsync(RedisKey key, long iterator)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.ScanDump(key, iterator))).ToScanDumpTuple();
}
}
}
79 changes: 79 additions & 0 deletions src/NRedisStack/Bloom/BloomCommandsAsync.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using NRedisStack.Bloom.DataTypes;
using StackExchange.Redis;
namespace NRedisStack
{

public class BloomCommandsAsync : IBloomCommandsAsync
{
IDatabaseAsync _db;
public BloomCommandsAsync(IDatabaseAsync db)
{
_db = db;
}

/// <inheritdoc/>
public async Task<bool> AddAsync(RedisKey key, RedisValue item)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.Add(key, item))).ToString() == "1";
}


/// <inheritdoc/>
public async Task<long> CardAsync(RedisKey key)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.Card(key))).ToLong();
}

/// <inheritdoc/>
public async Task<bool> ExistsAsync(RedisKey key, RedisValue item)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.Exists(key, item))).ToString() == "1";
}

/// <inheritdoc/>
public async Task<BloomInformation> InfoAsync(RedisKey key)
{
var info = (await _db.ExecuteAsync(BloomCommandBuilder.Info(key)));
return info.ToBloomInfo();
}

/// <inheritdoc/>
public async Task<bool[]> InsertAsync(RedisKey key, RedisValue[] items, int? capacity = null,
double? error = null, int? expansion = null,
bool nocreate = false, bool nonscaling = false)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.Insert(key, items, capacity, error, expansion, nocreate, nonscaling))).ToBooleanArray();
}

/// <inheritdoc/>
public async Task<bool> LoadChunkAsync(RedisKey key, long iterator, Byte[] data)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.LoadChunk(key, iterator, data))).OKtoBoolean();
}

/// <inheritdoc/>
public async Task<bool[]> MAddAsync(RedisKey key, params RedisValue[] items)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.MAdd(key, items))).ToBooleanArray();
}

/// <inheritdoc/>
public async Task<bool[]> MExistsAsync(RedisKey key, RedisValue[] items)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.MExists(key, items))).ToBooleanArray();
}

/// <inheritdoc/>
public async Task<bool> ReserveAsync(RedisKey key, double errorRate, long capacity,
int? expansion = null, bool nonscaling = false)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.Reserve(key, errorRate, capacity, expansion, nonscaling))).OKtoBoolean();
}

/// <inheritdoc/>
public async Task<Tuple<long, Byte[]>> ScanDumpAsync(RedisKey key, long iterator)
{
return (await _db.ExecuteAsync(BloomCommandBuilder.ScanDump(key, iterator))).ToScanDumpTuple();
}
}
}
Loading