Skip to content

Commit

Permalink
Rename projects
Browse files Browse the repository at this point in the history
  • Loading branch information
TonWin618 committed Apr 10, 2024
1 parent 8a1d947 commit 01505ac
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 51 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Microsoft.Extensions.Caching.Dapr
# TonWinPkg.Extensions.Caching.Dapr

### Introduction

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34616.47
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Caching.Dapr", "src\Microsoft.Extensions.Caching.Dapr.csproj", "{A42BB71E-99FF-4DAE-93FB-24299CDBED06}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TonWinPkg.Extensions.Caching.Dapr", "src\TonWinPkg.Extensions.Caching.Dapr.csproj", "{A42BB71E-99FF-4DAE-93FB-24299CDBED06}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Caching.Dapr.Test", "test\Microsoft.Extensions.Caching.Dapr.Test.csproj", "{AE77B07E-3212-4333-8BB6-11E8AC94D8EA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TonWinPkg.Extensions.Caching.Dapr.Test", "test\TonWinPkg.Extensions.Caching.Dapr.Test.csproj", "{AE77B07E-3212-4333-8BB6-11E8AC94D8EA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
23 changes: 12 additions & 11 deletions src/DaprCache.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using Dapr.Client;
using Microsoft.Extensions.Caching.Dapr.Shared;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using TonWinPkg.Extensions.Caching.Dapr.Shared;

namespace Microsoft.Extensions.Caching.Dapr
namespace TonWinPkg.Extensions.Caching.Dapr
{
public class DaprCache : IDistributedCache
{
Expand All @@ -15,12 +16,12 @@ public class DaprCache : IDistributedCache
private readonly ILogger _logger;

public DaprCache(IOptions<DaprCacheOptions> optionsAccessor)
: this(optionsAccessor, Logging.Abstractions.NullLoggerFactory.Instance.CreateLogger<DaprCache>())
: this(optionsAccessor, NullLoggerFactory.Instance.CreateLogger<DaprCache>())
{

}

public DaprCache(IOptions<DaprCacheOptions> optionsAccessor, ILogger logger)
public DaprCache(IOptions<DaprCacheOptions> optionsAccessor, ILogger logger)
{
ArgumentNullThrowHelper.ThrowIfNull(optionsAccessor);
ArgumentNullThrowHelper.ThrowIfNull(logger);
Expand All @@ -32,7 +33,7 @@ public DaprCache(IOptions<DaprCacheOptions> optionsAccessor, ILogger logger)
_logger = logger;

var builder = new DaprClientBuilder();
if(_options.HttpEndPoint != null)
if (_options.HttpEndPoint != null)
{
builder.UseHttpEndpoint(_options.HttpEndPoint);
}
Expand All @@ -54,12 +55,12 @@ public DaprCache(IOptions<DaprCacheOptions> optionsAccessor, ILogger logger)

var extendedValue = await _client.GetStateAsync<ExtendedCacheValue?>(_options.StoreName, key, null, null, token);

if(extendedValue.HasValue == false)
if (extendedValue.HasValue == false)
{
return null;
}

if(extendedValue.Value.ValueBase64 == null)
if (extendedValue.Value.ValueBase64 == null)
{
return null;
}
Expand Down Expand Up @@ -114,7 +115,7 @@ public async Task RemoveAsync(string key, CancellationToken token = default)

if (await _client.CheckHealthAsync(token))
{
await _client.DeleteStateAsync(_options.StoreName, key,null,null,token);
await _client.DeleteStateAsync(_options.StoreName, key, null, null, token);
}
else
{
Expand All @@ -127,7 +128,7 @@ public void Set(string key, byte[] value, DistributedCacheEntryOptions options)
ArgumentNullThrowHelper.ThrowIfNull(key);
ArgumentNullThrowHelper.ThrowIfNull(value);
ArgumentNullThrowHelper.ThrowIfNull(options);

SetAsync(key, value, options).GetAwaiter().GetResult();
}

Expand All @@ -136,9 +137,9 @@ public async Task SetAsync(string key, byte[] value, DistributedCacheEntryOption
ArgumentNullThrowHelper.ThrowIfNull(key);
ArgumentNullThrowHelper.ThrowIfNull(value);
ArgumentNullThrowHelper.ThrowIfNull(options);

token.ThrowIfCancellationRequested();

if (await _client.CheckHealthAsync(token))
{
var (isSlidingExpiration, ttl) = CacheTtlCalculateHelper.CalculateTtlSeconds(options);
Expand Down
4 changes: 2 additions & 2 deletions src/DaprCacheOptions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Microsoft.Extensions.Options;

namespace Microsoft.Extensions.Caching.Dapr
namespace TonWinPkg.Extensions.Caching.Dapr
{
public class DaprCacheOptions: IOptions<DaprCacheOptions>
public class DaprCacheOptions : IOptions<DaprCacheOptions>
{
/// <summary>
/// Name of the State Store Component.
Expand Down
8 changes: 4 additions & 4 deletions src/DaprCacheServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Microsoft.Extensions.Caching.Dapr;
using Microsoft.Extensions.Caching.Dapr.Shared;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.DependencyInjection;
using TonWinPkg.Extensions.Caching.Dapr.Shared;

namespace Microsoft.Extensions.DependencyInjection;
namespace TonWinPkg.Extensions.Caching.Dapr;

public static class StackExchangeRedisCacheServiceCollectionExtensions
{
Expand Down
2 changes: 1 addition & 1 deletion src/ExtendedCacheValue.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Diagnostics;

namespace Microsoft.Extensions.Caching.Dapr
namespace TonWinPkg.Extensions.Caching.Dapr
{
internal struct ExtendedCacheValue
{
Expand Down
15 changes: 0 additions & 15 deletions src/Microsoft.Extensions.Caching.Dapr.csproj

This file was deleted.

4 changes: 2 additions & 2 deletions src/Shared/ArgumentNullThrowHelper.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace Microsoft.Extensions.Caching.Dapr.Shared
namespace TonWinPkg.Extensions.Caching.Dapr.Shared
{
internal static partial class ArgumentNullThrowHelper
{
/// <summary>Throws an <see cref="ArgumentNullException"/> if <paramref name="argument"/> is null.</summary>
/// <param name="argument">The reference type argument to validate as non-null.</param>
/// <param name="paramName">The name of the parameter with which <paramref name="argument"/> corresponds.</param>
public static void ThrowIfNull(
[NotNull] object? argument,
[NotNull] object? argument,
[CallerArgumentExpression("argument")] string? paramName = null)
{
ArgumentNullException.ThrowIfNull(argument, paramName);
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/CacheTtlCalculateHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Caching.Distributed;

namespace Microsoft.Extensions.Caching.Dapr.Shared
namespace TonWinPkg.Extensions.Caching.Dapr.Shared
{
internal static class CacheTtlCalculateHelper
{
Expand Down
41 changes: 41 additions & 0 deletions src/TonWinPkg.Extensions.Caching.Dapr.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<Authors>TonWin</Authors>
<PackageIcon>dapr.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageProjectUrl></PackageProjectUrl>
<Description>Implemented Microsoft.Extensions.Caching.Abstractions using Dapr's state store.</Description>
<RepositoryUrl>https://github.com/TonWin618/Caching-Dapr</RepositoryUrl>
<RepositoryType></RepositoryType>
<PackageTags>Dapr DistributedCache Caching Cache</PackageTags>
<Version>1.0.1-alpha</Version>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\..\Download\dapr.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\LICENSE.txt">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Dapr.Client" Version="1.13.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion test/DaprCacheSetAndRemoveTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Runtime.CompilerServices;
using System.Text;

namespace Microsoft.Extensions.Caching.Dapr.Test;
namespace TonWinPkg.Extensions.Caching.Dapr.Test;

public class DaprCacheSetAndRemoveTests
{
Expand Down
5 changes: 3 additions & 2 deletions test/DaprTestConfig.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Extensions.Caching.Distributed;
using TonWinPkg.Extensions.Caching.Dapr;
using Microsoft.Extensions.Caching.Distributed;

namespace Microsoft.Extensions.Caching.Dapr.Test;
namespace TonWinPkg.Extensions.Caching.Dapr.Test;

internal class DaprTestConfig
{
Expand Down
6 changes: 3 additions & 3 deletions test/TimeExpirationTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.Extensions.Caching.Distributed;
using System.Runtime.CompilerServices;

namespace Microsoft.Extensions.Caching.Dapr.Test;
namespace TonWinPkg.Extensions.Caching.Dapr.Test;

public class TimeExpirationTests
{
Expand Down Expand Up @@ -34,7 +34,7 @@ public void AbsoluteExpirationExpires()
byte[] result = cache.Get(key);
Assert.Equal(value, result);

for (int i = 0; i < 4 && (result != null); i++)
for (int i = 0; i < 4 && result != null; i++)
{
Thread.Sleep(TimeSpan.FromSeconds(0.5));
result = cache.Get(key);
Expand Down Expand Up @@ -98,7 +98,7 @@ public void RelativeExpirationExpires()
var result = cache.Get(key);
Assert.Equal(value, result);

for (int i = 0; i < 4 && (result != null); i++)
for (int i = 0; i < 4 && result != null; i++)
{
Thread.Sleep(TimeSpan.FromSeconds(0.5));
result = cache.Get(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,15 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\Microsoft.Extensions.Caching.Dapr.csproj" />
<ProjectReference Include="..\src\TonWinPkg.Extensions.Caching.Dapr.csproj" />
</ItemGroup>

</Project>

0 comments on commit 01505ac

Please sign in to comment.