Skip to content

Commit

Permalink
Version 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JonPSmith committed Nov 15, 2022
1 parent 9593fb0 commit 05c4c59
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -18,14 +19,12 @@

<PropertyGroup>
<PackageId>Net.DistributedFileStoreCache</PackageId>
<PackageVersion>1.2.0-preview001</PackageVersion>
<PackageVersion>2.0.0</PackageVersion>
<Authors>Jon P Smith</Authors>
<Description>A fast .NET distributed cache using a json file as the shared resource</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>
- 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
</PackageReleaseNotes>
<Copyright>Copyright (c) 2022 Jon P Smith. Licenced under MIT licence</Copyright>
<PackageTags>Distributed cache</PackageTags>
Expand Down
5 changes: 5 additions & 0 deletions Net.DistributedFileStoreCache/SupportCode/CacheFileHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ private async ValueTask UpdateLocalCacheFromCacheFileAsync(CancellationToken tok
StaticCachePart.UpdateLocalCache(GetJsonFromByteBuffer(numBytesRead, ref readBuffer));
}
}

/// <summary>
/// delegate to use in methods
/// </summary>
/// <param name="updateCurrentJson"></param>
public delegate void UpdateJsonDelegate(ref CacheJsonContent updateCurrentJson);

private async ValueTask ReadAndChangeCacheJsonFile(UpdateJsonDelegate? updateCurrentJson, bool useAsync,
Expand Down
44 changes: 22 additions & 22 deletions Net.DistributedFileStoreCache/SupportCode/ValueTaskSyncCheckers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,29 @@ public static TResult CheckSyncValueTaskWorkedAndReturnResult<TResult>(this Valu
return valueTask.GetAwaiter().GetResult();
}

public static TResult CheckSyncValueTaskWorkedDynamicAndReturnResult<TResult>(dynamic dynamicValueType)
{
try
{
var runner = Activator.CreateInstance(typeof(GenericValueTypeChecker<TResult>),
dynamicValueType);
return ((GenericValueTypeChecker<TResult>)runner).Result;
}
catch (Exception e)
{
ExceptionDispatchInfo.Capture(e?.InnerException ?? e).Throw();
}
//public static TResult CheckSyncValueTaskWorkedDynamicAndReturnResult<TResult>(dynamic dynamicValueType)
//{
// try
// {
// var runner = Activator.CreateInstance(typeof(GenericValueTypeChecker<TResult>),
// dynamicValueType);
// return ((GenericValueTypeChecker<TResult>)runner).Result;
// }
// catch (Exception e)
// {
// ExceptionDispatchInfo.Capture(e?.InnerException ?? e).Throw();
// }

return default;
}
// return default;
//}

private class GenericValueTypeChecker<TResult>
{
public GenericValueTypeChecker(dynamic valueTask)
{
Result = CheckSyncValueTaskWorkedAndReturnResult(((ValueTask<TResult>)valueTask));
}
//private class GenericValueTypeChecker<TResult>
//{
// public GenericValueTypeChecker(dynamic valueTask)
// {
// Result = CheckSyncValueTaskWorkedAndReturnResult(((ValueTask<TResult>)valueTask));
// }

public TResult Result { get; }
}
// public TResult Result { get; }
//}
}
4 changes: 4 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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":{}}
{"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":{}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Cache":{"test":"{\"MyInt\":1,\"MyString\":\"Hello\"}"},"TimeOuts":{}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Cache":{"test-timeoutExpired":"time1"},"TimeOuts":{"test-timeoutExpired":638012624251983534}}
{"Cache":{"test-timeoutExpired":"time1"},"TimeOuts":{"test-timeoutExpired":638041088939418683}}
3 changes: 2 additions & 1 deletion Test/TestHelpers/ParallelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public static async IAsyncEnumerable<int> NumTimesAsyncEnumerable(this int numTi
}


public static async Task AsyncParallelForEach<T>(this IAsyncEnumerable<T> source, Func<T, Task> body, int maxDegreeOfParallelism = DataflowBlockOptions.Unbounded, TaskScheduler scheduler = null)
public static async Task AsyncParallelForEach<T>(this IAsyncEnumerable<T> source, Func<T, Task> body,
int maxDegreeOfParallelism = DataflowBlockOptions.Unbounded, TaskScheduler scheduler = null)
{
var options = new ExecutionDataflowBlockOptions
{
Expand Down

0 comments on commit 05c4c59

Please sign in to comment.