Skip to content

Commit

Permalink
Merge branch 'release/2020.8.21.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Robertson committed Aug 21, 2020
2 parents 7d5b27b + 8d760d4 commit efae42e
Show file tree
Hide file tree
Showing 12 changed files with 193 additions and 509 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,4 @@ $RECYCLE.BIN/
/EFCache.Redis.Tests/lib/dump.rdb
.vs/
*.nupkg
*.orig
45 changes: 0 additions & 45 deletions EFCache.Redis.Tests/App.config

This file was deleted.

266 changes: 18 additions & 248 deletions EFCache.Redis.Tests/EFCache.Redis.Tests.csproj

Large diffs are not rendered by default.

88 changes: 84 additions & 4 deletions EFCache.Redis.Tests/RedisCacheTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using EFCache.Redis.Tests.Annotations;
using EFCache.Redis.Tests.Annotations;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using StackExchange.Redis;
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace EFCache.Redis.Tests
{
Expand All @@ -20,6 +22,7 @@ public class RedisCacheTests
{
private readonly string RegularConnectionString = "localhost:6379";
private readonly string AdminConnectionString = "localhost:6379,allowAdmin=true";

public RedisCacheTests()
{
try
Expand Down Expand Up @@ -152,6 +155,83 @@ public void Count_returns_numers_of_cached_entries()
Assert.AreEqual(0, cache.Count);
}


[TestMethod]
public async Task ThreadingBlockTest()
{
var cache = new RedisCache("localhost:6379,allowAdmin=true");

Exception exception = null;

cache.LockWaitTimeout = 10;

cache.CachingFailed += (sender, e) =>
{
if (e?.InnerException is LockTimeoutException)
exception = e.InnerException;
};
cache.Purge();

Assert.AreEqual(0, cache.Count);

var crazyLargeResultSet = Enumerable.Range(1, 100000).Select(a => $"String {a}").ToArray();

cache.PutItem("1", crazyLargeResultSet, new[] { "ES1", "ES2" }, TimeSpan.MaxValue, DateTimeOffset.MaxValue);
cache.PutItem("2", crazyLargeResultSet, new[] { "ES1", "ES2" }, TimeSpan.MaxValue, DateTimeOffset.MaxValue);
cache.PutItem("3", crazyLargeResultSet, new[] { "ES1", "ES2" }, TimeSpan.MaxValue, DateTimeOffset.MaxValue);

// Assert.Equal(3, cache.Count); // "1", "ES1", "ES2"


var tasks = new Task[10];

for (var i = 0; i < 10; i++)
{
var icopy = i;
tasks[i] = Task.Run(() =>
{
var watch = new Stopwatch();
watch.Start();
Debug.WriteLine($"Invalidate {icopy} start");
if (i == 9)
cache.InvalidateItem("1");
else
{
object val;
cache.GetItem("1", out val);
}
watch.Stop();
Debug.WriteLine($"Invalidate {icopy} complete after {watch.ElapsedMilliseconds}");
});
}


var threadGet = Task.Run(() =>
{
Debug.WriteLine($"Get start");
var watch = new Stopwatch();
watch.Start();
object value;
cache.GetItem("1", out value);
watch.Stop();
Debug.WriteLine($"Get complete after {watch.ElapsedMilliseconds}");
});


await threadGet;
await Task.WhenAll(tasks);

Assert.IsNotNull(exception);
Assert.IsInstanceOfType(exception, typeof(LockTimeoutException));


}

private void Cache_CachingFailed(object sender, RedisCacheException e)
{
throw new NotImplementedException();
}


[TestMethod]
public void Count_does_not_return_expired_entries()
Expand Down
5 changes: 2 additions & 3 deletions EFCache.Redis.Tests/RedisStorageEmulatorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ public class RedisStorageEmulatorManager : StorageEmulatorManager

private static string GetLibFolder()
{
var binFolder = Directory.GetParent(AssemblyDirectory);
var projectFolder = Directory.GetParent(binFolder.FullName);


var pathToLibFolder = Path.Combine(projectFolder.FullName, "lib");
var pathToLibFolder = Path.Combine(AssemblyDirectory, "lib");

return pathToLibFolder;

Expand Down
34 changes: 0 additions & 34 deletions EFCache.Redis/App.config

This file was deleted.

137 changes: 9 additions & 128 deletions EFCache.Redis/EFCache.Redis.csproj
Original file line number Diff line number Diff line change
@@ -1,132 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{EAADFBA4-DC52-4CEF-AC76-309B50B3A05E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EFCache.Redis</RootNamespace>
<AssemblyName>EFCache.Redis</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<TargetFrameworkProfile />
<TargetFramework>net48</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Reference Include="EFCache, Version=1.1.3.0, Culture=neutral, PublicKeyToken=46c4868af4307d2c, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.Cache.1.1.3\lib\net45\EFCache.dll</HintPath>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="Pipelines.Sockets.Unofficial, Version=1.0.0.0, Culture=neutral, PublicKeyToken=42ea0a778e13fbe2, processorArchitecture=MSIL">
<HintPath>..\packages\Pipelines.Sockets.Unofficial.1.1.23\lib\net472\Pipelines.Sockets.Unofficial.dll</HintPath>
</Reference>
<Reference Include="StackExchange.Redis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46, processorArchitecture=MSIL">
<HintPath>..\packages\StackExchange.Redis.2.0.519\lib\net472\StackExchange.Redis.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Diagnostics.PerformanceCounter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.PerformanceCounter.4.5.0\lib\net461\System.Diagnostics.PerformanceCounter.dll</HintPath>
</Reference>
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.Pipelines, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Pipelines.4.5.3\lib\netstandard2.0\System.IO.Pipelines.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.2\lib\netstandard2.0\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Channels, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Channels.4.5.0\lib\netstandard2.0\System.Threading.Channels.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CacheEntry.cs" />
<Compile Include="Guard.cs" />
<Compile Include="IRedisCache.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>AssemblyInfo.tt</DependentUpon>
</Compile>
<Compile Include="RedisCache.cs" />
<Compile Include="RedisCacheException.cs" />
<Compile Include="StackExchangeRedisExtensions.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
<None Include="Properties\AssemblyInfo.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AssemblyInfo.cs</LastGenOutput>
</None>
</ItemGroup>

<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
<PackageReference Include="EntityFramework.Cache" Version="1.3.1" />
<PackageReference Include="StackExchange.Redis" Version="2.1.58" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

</Project>
Loading

0 comments on commit efae42e

Please sign in to comment.