diff --git a/Net.DistributedFileStoreCache/Net.DistributedFileStoreCache.csproj b/Net.DistributedFileStoreCache/Net.DistributedFileStoreCache.csproj index e34f2f5..b3d982b 100644 --- a/Net.DistributedFileStoreCache/Net.DistributedFileStoreCache.csproj +++ b/Net.DistributedFileStoreCache/Net.DistributedFileStoreCache.csproj @@ -1,7 +1,8 @@  - net6.0 + netstandard2.1 + latest enable enable true @@ -18,14 +19,12 @@ Net.DistributedFileStoreCache - 1.2.0-preview001 + 2.0.0 Jon P Smith A fast .NET distributed cache using a json file as the shared resource false -- New Feature: SetMany / SetManyAsync now allows you to many entries in one go. This can add many entries as quickly as a single Set call. -- New Feature: SetManyClass / SetManyClassAsync now allows you to many entries in one go. This can add many entries as quickly as a single SetClass call. -- New Feature: ClearAll now has an option to add a list of key/value pairs into the json cache file after the cache is cleared + Changed target framework to netstandard2.1 to work with any version of .NET Copyright (c) 2022 Jon P Smith. Licenced under MIT licence Distributed cache diff --git a/Net.DistributedFileStoreCache/SupportCode/CacheFileHandler.cs b/Net.DistributedFileStoreCache/SupportCode/CacheFileHandler.cs index 3ab837a..548148f 100644 --- a/Net.DistributedFileStoreCache/SupportCode/CacheFileHandler.cs +++ b/Net.DistributedFileStoreCache/SupportCode/CacheFileHandler.cs @@ -236,6 +236,11 @@ private async ValueTask UpdateLocalCacheFromCacheFileAsync(CancellationToken tok StaticCachePart.UpdateLocalCache(GetJsonFromByteBuffer(numBytesRead, ref readBuffer)); } } + + /// + /// delegate to use in methods + /// + /// public delegate void UpdateJsonDelegate(ref CacheJsonContent updateCurrentJson); private async ValueTask ReadAndChangeCacheJsonFile(UpdateJsonDelegate? updateCurrentJson, bool useAsync, diff --git a/Net.DistributedFileStoreCache/SupportCode/ValueTaskSyncCheckers.cs b/Net.DistributedFileStoreCache/SupportCode/ValueTaskSyncCheckers.cs index 7468626..8ed4587 100644 --- a/Net.DistributedFileStoreCache/SupportCode/ValueTaskSyncCheckers.cs +++ b/Net.DistributedFileStoreCache/SupportCode/ValueTaskSyncCheckers.cs @@ -38,29 +38,29 @@ public static TResult CheckSyncValueTaskWorkedAndReturnResult(this Valu return valueTask.GetAwaiter().GetResult(); } - public static TResult CheckSyncValueTaskWorkedDynamicAndReturnResult(dynamic dynamicValueType) - { - try - { - var runner = Activator.CreateInstance(typeof(GenericValueTypeChecker), - dynamicValueType); - return ((GenericValueTypeChecker)runner).Result; - } - catch (Exception e) - { - ExceptionDispatchInfo.Capture(e?.InnerException ?? e).Throw(); - } + //public static TResult CheckSyncValueTaskWorkedDynamicAndReturnResult(dynamic dynamicValueType) + //{ + // try + // { + // var runner = Activator.CreateInstance(typeof(GenericValueTypeChecker), + // dynamicValueType); + // return ((GenericValueTypeChecker)runner).Result; + // } + // catch (Exception e) + // { + // ExceptionDispatchInfo.Capture(e?.InnerException ?? e).Throw(); + // } - return default; - } + // return default; + //} - private class GenericValueTypeChecker - { - public GenericValueTypeChecker(dynamic valueTask) - { - Result = CheckSyncValueTaskWorkedAndReturnResult(((ValueTask)valueTask)); - } + //private class GenericValueTypeChecker + //{ + // public GenericValueTypeChecker(dynamic valueTask) + // { + // Result = CheckSyncValueTaskWorkedAndReturnResult(((ValueTask)valueTask)); + // } - public TResult Result { get; } - } + // public TResult Result { get; } + //} } \ No newline at end of file diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 76bc9ad..7792924 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,5 +1,9 @@ # Release Notes +## 2.0.0 + +- Changed target framework to netstandard2.1 to work with any version of .NET + ## 1.1.0 - New Feature: SetMany / SetManyAsync now allows you to many entries in one go. This can add many entries as quickly as a single Set call. diff --git a/Test/TestData/FileStoreCacheFile.TestCacheServiceParallel.json b/Test/TestData/FileStoreCacheFile.TestCacheServiceParallel.json index 69ba967..c430871 100644 --- a/Test/TestData/FileStoreCacheFile.TestCacheServiceParallel.json +++ b/Test/TestData/FileStoreCacheFile.TestCacheServiceParallel.json @@ -1 +1 @@ -{"Cache":{"Key4":"Diff = 1.112 ms","Key3":"Diff = 1.139 ms","Key2":"Diff = 1.192 ms","Key1":"Diff = 19.347 ms","Key5":"Diff = 1.166 ms"},"TimeOuts":{}} \ No newline at end of file +{"Cache":{"Key4":"Diff = 1.074 ms","Key2":"Diff = 1.160 ms","Key1":"Diff = 13.030 ms","Key3":"Diff = 1.098 ms","Key5":"Diff = 1.155 ms"},"TimeOuts":{}} \ No newline at end of file diff --git a/Test/TestData/FileStoreCacheFile.TestDistributedFileStoreCacheClassAsync.json b/Test/TestData/FileStoreCacheFile.TestDistributedFileStoreCacheClassAsync.json new file mode 100644 index 0000000..26269f5 --- /dev/null +++ b/Test/TestData/FileStoreCacheFile.TestDistributedFileStoreCacheClassAsync.json @@ -0,0 +1 @@ +{"Cache":{"test":"{\"MyInt\":1,\"MyString\":\"Hello\"}"},"TimeOuts":{}} \ No newline at end of file diff --git a/Test/TestData/FileStoreCacheFile.TestDistributedFileStoreCacheString_Async.json b/Test/TestData/FileStoreCacheFile.TestDistributedFileStoreCacheString_Async.json index 9504416..ef091c8 100644 --- a/Test/TestData/FileStoreCacheFile.TestDistributedFileStoreCacheString_Async.json +++ b/Test/TestData/FileStoreCacheFile.TestDistributedFileStoreCacheString_Async.json @@ -1 +1 @@ -{"Cache":{"test-timeoutExpired":"time1"},"TimeOuts":{"test-timeoutExpired":638012624251983534}} \ No newline at end of file +{"Cache":{"test-timeoutExpired":"time1"},"TimeOuts":{"test-timeoutExpired":638041088939418683}} \ No newline at end of file diff --git a/Test/TestHelpers/ParallelExtensions.cs b/Test/TestHelpers/ParallelExtensions.cs index 1ba39fa..00c952e 100644 --- a/Test/TestHelpers/ParallelExtensions.cs +++ b/Test/TestHelpers/ParallelExtensions.cs @@ -19,7 +19,8 @@ public static async IAsyncEnumerable NumTimesAsyncEnumerable(this int numTi } - public static async Task AsyncParallelForEach(this IAsyncEnumerable source, Func body, int maxDegreeOfParallelism = DataflowBlockOptions.Unbounded, TaskScheduler scheduler = null) + public static async Task AsyncParallelForEach(this IAsyncEnumerable source, Func body, + int maxDegreeOfParallelism = DataflowBlockOptions.Unbounded, TaskScheduler scheduler = null) { var options = new ExecutionDataflowBlockOptions {