From f8c997df9c3f611a8261b12de97484fda3a8c771 Mon Sep 17 00:00:00 2001 From: Kwaku Boamah Date: Tue, 12 Mar 2024 11:32:51 +0000 Subject: [PATCH] clean up --- src/NQuery.Core/Interfaces/INQuery.cs | 12 ++++++------ src/NQuery.Core/NQuery.cs | 26 +++++++++++++------------- src/NQuery.Test/AspNetQueryTest.cs | 6 ++---- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/NQuery.Core/Interfaces/INQuery.cs b/src/NQuery.Core/Interfaces/INQuery.cs index d686465..bca12a5 100644 --- a/src/NQuery.Core/Interfaces/INQuery.cs +++ b/src/NQuery.Core/Interfaces/INQuery.cs @@ -2,15 +2,15 @@ namespace NQuery.Core.Interfaces; public interface INQuery { - Task QueryAsync( + Task QueryAsync( string key, - Func> query); + Func> query); - Task> QueryAsync( + Task> QueryAsync( string key, - Func>> query); + Func>> query); - Task MutationAsync( + Task MutationAsync( string key, - Func> mutate); + Func> mutate); } \ No newline at end of file diff --git a/src/NQuery.Core/NQuery.cs b/src/NQuery.Core/NQuery.cs index 9378297..c6d4a58 100644 --- a/src/NQuery.Core/NQuery.cs +++ b/src/NQuery.Core/NQuery.cs @@ -60,33 +60,33 @@ public static NQuery Create(NQueryConfiguration configuration) return new NQuery(configuration, ConnectionMultiplexer.Connect(stackExchangeRedisConfig)); } - public async Task QueryAsync(string key, Func> query) + public async Task QueryAsync(string key, Func> query) { return _configuration.UseInMemory ? await InMemoryQuery(key, query) : await ExternalQuery(key, query); } - public async Task> QueryAsync(string key, Func>> query) + public async Task> QueryAsync(string key, Func>> query) { return _configuration.UseInMemory ? await InMemoryQuery(key, query) : await ExternalQuery(key, query); } - public async Task MutationAsync(string key, Func> mutate) + public async Task MutationAsync(string key, Func> mutate) { return _configuration.UseInMemory ? await InMemoryMutate(key, mutate) : await ExternalMutate(key, mutate); } - private async Task InMemoryQuery(string key, Func> query) + private async Task InMemoryQuery(string key, Func> query) { // check if key is already set if (_memoryDb.TryGetValue(key, out var value)) { - return (TOutput)value; + return (T)value; } // key not set @@ -99,12 +99,12 @@ private async Task InMemoryQuery(string key, Func> InMemoryQuery(string key, Func>> query) + private async Task> InMemoryQuery(string key, Func>> query) { // check if key is already set if (_memoryDb.TryGetValue(key, out var value)) { - return (IEnumerable)value; + return (IEnumerable)value; } // key not set @@ -118,7 +118,7 @@ private async Task> InMemoryQuery(string key, Func return rstLst; } - private async Task InMemoryMutate(string key, Func> mutate) + private async Task InMemoryMutate(string key, Func> mutate) { // check if key is already set if (_memoryDb.ContainsKey(key)) @@ -129,13 +129,13 @@ private async Task> InMemoryQuery(string key, Func return await mutate(); } - private async Task ExternalQuery(string key, Func> query) + private async Task ExternalQuery(string key, Func> query) { // check if key is already set var exist = await _redisDb.StringGetAsync(new RedisKey(key)); if (!exist.IsNull) { - return JsonSerializer.Deserialize(exist!); + return JsonSerializer.Deserialize(exist!); } // key not set @@ -149,13 +149,13 @@ await _redisDb.StringSetAsync( return rst; } - private async Task> ExternalQuery(string key, Func>> query) + private async Task> ExternalQuery(string key, Func>> query) { // check if key is already set var exist = await _redisDb.StringGetAsync(new RedisKey(key)); if (!exist.IsNull) { - return JsonSerializer.Deserialize>(exist); + return JsonSerializer.Deserialize>(exist); } // key not set @@ -170,7 +170,7 @@ await _redisDb.StringSetAsync( return rstLst; } - private async Task ExternalMutate(string key, Func> mutate) + private async Task ExternalMutate(string key, Func> mutate) { // check if key is already set var exist = await _redisDb.StringGetAsync(new RedisKey(key)); diff --git a/src/NQuery.Test/AspNetQueryTest.cs b/src/NQuery.Test/AspNetQueryTest.cs index 854edd2..1d7bbb4 100644 --- a/src/NQuery.Test/AspNetQueryTest.cs +++ b/src/NQuery.Test/AspNetQueryTest.cs @@ -7,7 +7,7 @@ namespace NQuery.Test; public class AspNetQueryTest { - readonly ServiceCollection _services = new ServiceCollection(); + private readonly ServiceCollection _services = new ServiceCollection(); [SetUp] public void Setup() @@ -17,9 +17,7 @@ public void Setup() cfg.UseRedis(opts => { opts.Endpoints.Add(new RedisEndpoint() { Host = "127.0.0.1", Port = 6379 }); - opts.AbortOnConnectFail = false; - opts.ResolveDns = true; - opts.UseSsl = false; + opts.AbortOnConnectFail = false; }); }); }