Skip to content

Commit

Permalink
Merge pull request #22 from App-vNext/v20dev
Browse files Browse the repository at this point in the history
Release v2.0
  • Loading branch information
joelhulen authored Jun 14, 2018
2 parents 262dd9c + cb40671 commit bd19386
Show file tree
Hide file tree
Showing 44 changed files with 246 additions and 860 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Polly.Caching.MemoryCache change log

## 2.0.0
- Provide a single signed package only.
- Reference Polly v6.0.1.
- Remove .net 4 and 4.5 support.
- Add .net standard 2.0 as a target framework.
- Change namespaces from Polly.Caching.MemoryCache to Polly.Caching.Memory to avoid clashes.

## 1.1.0

- Polly.Caching.MemoryCache-Signed now references Polly-Signed
Expand Down
2 changes: 1 addition & 1 deletion GitVersionConfig.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
next-version: 1.1.0
next-version: 2.0.0
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
# Polly.Caching.MemoryCache
# Polly.Caching.Memory

This repo contains the MemoryCache plugin for the [Polly](https://github.com/App-vNext/Polly) [Cache policy](https://github.com/App-vNext/Polly/wiki/Cache). It targets .NET 4.0, .NET 4.5 and .NET Standard 1.3.
This repo contains the MemoryCache plugin for the [Polly](https://github.com/App-vNext/Polly) [Cache policy](https://github.com/App-vNext/Polly/wiki/Cache). The current version targets .NET Standard 1.3 and .NET Standard 2.0.

[![NuGet version](https://badge.fury.io/nu/Polly.Caching.MemoryCache.svg)](https://badge.fury.io/nu/Polly.Caching.MemoryCache) [![Build status](https://ci.appveyor.com/api/projects/status/pgd89nfdr9u4ig8m?svg=true)](https://ci.appveyor.com/project/joelhulen/polly-caching-memorycache) [![Slack Status](http://www.pollytalk.org/badge.svg)](http://www.pollytalk.org)
[![NuGet version](https://badge.fury.io/nu/Polly.Caching.Memory.svg)](https://badge.fury.io/nu/Polly.Caching.Memory) [![Build status](https://ci.appveyor.com/api/projects/status/pgd89nfdr9u4ig8m?svg=true)](https://ci.appveyor.com/project/joelhulen/polly-caching-Memory) [![Slack Status](http://www.pollytalk.org/badge.svg)](http://www.pollytalk.org)

## What is Polly?

[Polly](https://github.com/App-vNext/Polly) is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, Cache aside and Fallback in a fluent and thread-safe manner. Polly targets .NET 4.0, .NET 4.5 and .NET Standard 1.1.
[Polly](https://github.com/App-vNext/Polly) is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, Cache aside and Fallback in a fluent and thread-safe manner. Polly targets .NET Standard 1.1 and .NET Standrad 2.0.

Polly is a member of the [.NET Foundation](https://www.dotnetfoundation.org/about)!

**Keep up to date with new feature announcements, tips & tricks, and other news through [www.thepollyproject.org](http://www.thepollyproject.org)**

![](https://raw.github.com/App-vNext/Polly/master/Polly-Logo.png)

# Installing Polly.Caching.MemoryCache via NuGet
# Installing Polly.Caching.Memory via NuGet

Install-Package Polly.Caching.MemoryCache
Install-Package Polly.Caching.Memory

You can install the Strongly Named version via:

Install-Package Polly.Caching.MemoryCache-Signed

# Supported targets

Polly.Caching.MemoryCache supports .NET4.0, .NET4.5 and .NetStandard 1.3.
Polly.Caching.Memory >= v2.0 supports .NET Standard 1.3 and .NET Standard 2.0.

Polly.Caching.MemoryCache <v2.0 supports .NET4.0, .NET4.5 and .NetStandard 1.3

## Dependencies

Polly.Caching.MemoryCache works with Polly v5.9.0 and above.
Polly.Caching.Memory >= v2.0 works with Polly v6.0.1 and above.

Polly.Caching.MemoryCache <v2.0 works with Polly v5.9.0 and above.

# How to use the Polly.Caching.MemoryCache plugin
# How to use the Polly.Caching.Memory plugin

```csharp
// (1a): Create a MemoryCacheProvider instance in the .NET Framework, using the Polly.Caching.MemoryCache nuget package.
// (1a): Create a MemoryCacheProvider instance in the .NET Framework, using the Polly.Caching.Memory nuget package.
// (full namespaces and types only shown here for disambiguation)
Polly.Caching.MemoryCache.MemoryCacheProvider memoryCacheProvider
= new Polly.Caching.MemoryCache.MemoryCacheProvider(System.Runtime.Caching.MemoryCache.Default);
Polly.Caching.Memory.MemoryCacheProvider memoryCacheProvider
= new Polly.Caching.Memory.MemoryCacheProvider(System.Runtime.Caching.MemoryCache.Default);

// Or (1b): Create a MemoryCacheProvider instance in .NET Core / .NET Standard.
// (full namespaces and types only shown here for disambiguation)
// NB Only if you want to create your own Microsoft.Extensions.Caching.Memory.MemoryCache instance:
Microsoft.Extensions.Caching.Memory.IMemoryCache memoryCache
= new Microsoft.Extensions.Caching.Memory.MemoryCache(new Microsoft.Extensions.Caching.Memory.MemoryCacheOptions());
Polly.Caching.MemoryCache.MemoryCacheProvider memoryCacheProvider
= new Polly.Caching.MemoryCache.MemoryCacheProvider(memoryCache);
Polly.Caching.Memory.MemoryCacheProvider memoryCacheProvider
= new Polly.Caching.Memory.MemoryCacheProvider(memoryCache);

// (2) Create a Polly cache policy using that Polly.Caching.MemoryCache.MemoryCacheProvider instance.
// (2) Create a Polly cache policy using that Polly.Caching.Memory.MemoryCacheProvider instance.
var cachePolicy = Policy.Cache(memoryCacheProvider, TimeSpan.FromMinutes(5));


Expand Down Expand Up @@ -99,6 +100,7 @@ For details of changes by release see the [change log](CHANGELOG.md).
* [@reisenberger](https://github.com/reisenberger) - MemoryCache implementation
* [@seanfarrow](https://github.com/seanfarrow) and [@reisenberger](https://github.com/reisenberger) - Initial caching architecture in the main Polly repo
* [@kesmy](https://github.com/kesmy) - original structuring of the build for msbuild15, in the main Polly repo
* [@seanfarrow](https://github.com/seanfarrow) - v2.0 update to Signed packages only to correspond with Polly v6.0.1


# Instructions for Contributing
Expand Down
173 changes: 66 additions & 107 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using System.Text.Json;
// GLOBAL VARIABLES
///////////////////////////////////////////////////////////////////////////////

var projectName = "Polly.Caching.MemoryCache";
var projectName = "Polly.Caching.Memory";
var keyName = "Polly.snk";

var solutions = GetFiles("./**/*.sln");
Expand All @@ -38,30 +38,27 @@ var testResultsDir = artifactsDir + Directory("test-results");

// NuGet
var nuspecExtension = ".nuspec";
var signed = "-Signed";
var nuspecFolder = "nuget-package";
var nuspecSrcFile = srcDir + File(projectName + nuspecExtension);
var nuspecDestFile = buildDir + File(projectName + nuspecExtension);
var nuspecSignedDestFile = buildDir + File(projectName + signed + nuspecExtension);
var nupkgDestDir = artifactsDir + Directory(nuspecFolder);
var snkFile = srcDir + File(keyName);

var projectToNugetFolderMap = new Dictionary<string, string[]>() {
{ "Net45" , new [] {"net45"} },
{ "NetStandard13" , new [] {"netstandard1.3"} },
{ "Net40Async" , new [] {"net40"} },
{ "Net45-Signed" , new [] {"net45"} },
{ "NetStandard13-Signed", new [] {"netstandard1.3"} },
{ "Net40Async-Signed" , new [] {"net40"} },
{ "NetStandard13", new [] {"netstandard1.3"} },
{ "NetStandard20", new [] {"netstandard2.0"} },
};

var netStandard = "NetStandard";
var specs = "Specs";

// Gitversion
var gitVersionPath = ToolsExePath("GitVersion.exe");
Dictionary<string, object> gitVersionOutput;

// Versioning
string nugetVersion;
string appveyorBuildNumber;
string assemblyVersion;
string assemblySemver;

// StrongNameSigner
var strongNameSignerPath = ToolsExePath("StrongNameSigner.Console.exe");

Expand All @@ -72,12 +69,13 @@ var strongNameSignerPath = ToolsExePath("StrongNameSigner.Console.exe");

Setup(_ =>
{
Information(@"");
Information(@" ____ __ __ __ _ _ ___ __ ___ _ _ __ __ _ ___ _ _ ____ _ _ __ ____ _ _ ___ __ ___ _ _ ____ ");
Information(@"( _ \ / \ ( ) ( ) ( \/ ) / __) / _\ / __)/ )( \( )( ( \ / __) ( \/ )( __)( \/ ) / \( _ \( \/ )/ __) / _\ / __)/ )( \( __)");
Information(@" ) __/( O )/ (_/\/ (_/\ ) /_( (__ / \( (__ ) __ ( )( / /( (_ \ _ / \/ \ ) _) / \/ \( O )) / ) /( (__ / \( (__ ) __ ( ) _) ");
Information(@"(__) \__/ \____/\____/(__/(_)\___)\_/\_/ \___)\_)(_/(__)\_)__) \___/(_)\_)(_/(____)\_)(_/ \__/(__\_)(__/ \___)\_/\_/ \___)\_)(_/(____)");
Information(@"");
// ASCII art via: http://patorjk.com/software/taag/?#p=display&f=Graceful&t=Polly.Caching.Memory%0A
Information("");
Information(@" ____ __ __ __ _ _ ___ __ ___ _ _ __ __ _ ___ _ _ ____ _ _ __ ____ _ _ ");
Information(@"( _ \ / \ ( ) ( ) ( \/ ) / __) / _\ / __)/ )( \( )( ( \ / __) ( \/ )( __)( \/ ) / \( _ \( \/ )");
Information(@" ) __/( O )/ (_/\/ (_/\ ) /_( (__ / \( (__ ) __ ( )( / /( (_ \ _ / \/ \ ) _) / \/ \( O )) / ) / ");
Information(@"(__) \__/ \____/\____/(__/(_)\___)\_/\_/ \___)\_)(_/(__)\_)__) \___/(_)\_)(_/(____)\_)(_/ \__/(__\_)(__/ ");
Information("");
});

Teardown(_ =>
Expand Down Expand Up @@ -134,38 +132,62 @@ Task("__UpdateAssemblyVersionInformation")
gitVersionOutput = new JsonParser().Parse<Dictionary<string, object>>(output);
Information("Updated GlobalAssemblyInfo");
Information("AssemblyVersion -> {0}", gitVersionOutput["AssemblySemVer"]);
Information("AssemblyFileVersion -> {0}", gitVersionOutput["MajorMinorPatch"]);
Information("AssemblyInformationalVersion -> {0}", gitVersionOutput["InformationalVersion"]);
Information("");
Information("Obtained raw version info for package versioning:");
Information("NuGetVersion -> {0}", gitVersionOutput["NuGetVersion"]);
Information("FullSemVer -> {0}", gitVersionOutput["FullSemVer"]);
Information("AssemblySemVer -> {0}", gitVersionOutput["AssemblySemVer"]);
appveyorBuildNumber = gitVersionOutput["FullSemVer"].ToString();
nugetVersion = gitVersionOutput["NuGetVersion"].ToString();
assemblyVersion = gitVersionOutput["Major"].ToString() + ".0.0.0";
assemblySemver = gitVersionOutput["AssemblySemVer"].ToString();
Information("");
Information("Mapping versioning information to:");
Information("Appveyor build number -> {0}", appveyorBuildNumber);
Information("Nuget package version -> {0}", nugetVersion);
Information("AssemblyVersion -> {0}", assemblyVersion);
Information("AssemblyFileVersion -> {0}", assemblySemver);
Information("AssemblyInformationalVersion -> {0}", assemblySemver);
});

Task("__UpdateDotNetStandardAssemblyVersionNumber")
.Does(() =>
{
// NOTE: TEMPORARY fix only, while GitVersionTask does not support .Net Standard assemblies. See https://github.com/App-vNext/Polly/issues/176.
// This build Task can be removed when GitVersionTask supports .Net Standard assemblies.
var assemblySemVer = gitVersionOutput["AssemblySemVer"].ToString();
Information("Updating NetStandard AssemblyVersions to {0}", assemblySemVer);
Information("Updating Assembly Version Information");
var attributeToValueMap = new Dictionary<string, string>() {
{ "AssemblyVersion", assemblyVersion },
{ "AssemblyFileVersion", assemblySemver },
{ "AssemblyInformationalVersion", assemblySemver },
};
var assemblyInfosToUpdate = GetFiles("./src/**/Properties/AssemblyInfo.cs")
.Select(f => f.FullPath)
.Where(f => f.Contains(netStandard))
.Where(f => !f.Contains(specs));
foreach(var assemblyInfo in assemblyInfosToUpdate) {
var replacedFiles = ReplaceRegexInFiles(assemblyInfo, "AssemblyVersion[(]\".*\"[)]", "AssemblyVersion(\"" + assemblySemVer +"\")");
if (!replacedFiles.Any())
{
throw new Exception("AssemblyVersion could not be updated in " + assemblyInfo + ".");
.Where(f => !f.Contains("Specs"));
foreach(var attributeMap in attributeToValueMap) {
var attribute = attributeMap.Key;
var value = attributeMap.Value;
foreach(var assemblyInfo in assemblyInfosToUpdate) {
var replacedFiles = ReplaceRegexInFiles(assemblyInfo, attribute + "[(]\".*\"[)]", attribute + "(\"" + value +"\")");
if (!replacedFiles.Any())
{
throw new Exception($"{attribute} attribute could not be updated in {assemblyInfo}.");
}
}
}
});

Task("__UpdateAppVeyorBuildNumber")
.WithCriteria(() => AppVeyor.IsRunningOnAppVeyor)
.Does(() =>
{
var fullSemVer = gitVersionOutput["FullSemVer"].ToString();
AppVeyor.UpdateBuildVersion(fullSemVer);
AppVeyor.UpdateBuildVersion(appveyorBuildNumber);
});

Task("__BuildSolutions")
Expand All @@ -188,33 +210,18 @@ Task("__BuildSolutions")
Task("__RunTests")
.Does(() =>
{
XUnit2("./src/**/bin/" + configuration + "/**/*.Net4*.Specs.dll", new XUnit2Settings {
OutputDirectory = testResultsDir,
XmlReportV1 = true
});
});

Task("__RunDotnetTests")
.Does(() =>
{
foreach(var specsProj in GetFiles("./src/**/*.Specs.csproj")
.Select(f => f.FullPath)
.Where(f => f.Contains(netStandard))
) {
DotNetCoreTest(specsProj, new DotNetCoreTestSettings {
Configuration = configuration,
NoBuild = true
foreach(var specsProj in GetFiles("./src/**/*.Specs.csproj")) {
DotNetCoreTest(specsProj.FullPath, new DotNetCoreTestSettings {
Configuration = configuration,
NoBuild = true
});
}
});


Task("__CopyNonSignedOutputToNugetFolder")
Task("__CopyOutputToNugetFolder")
.Does(() =>
{
foreach(var project in projectToNugetFolderMap.Keys
.Where(p => !p.Contains(signed))
) {
foreach(var project in projectToNugetFolderMap.Keys) {
var sourceDir = srcDir + Directory(projectName + "." + project) + Directory("bin") + Directory(configuration);
foreach(var targetFolder in projectToNugetFolderMap[project]) {
Expand All @@ -228,49 +235,6 @@ Task("__CopyNonSignedOutputToNugetFolder")
CopyFile(nuspecSrcFile, nuspecDestFile);
});

Task("__CopySignedOutputToNugetFolder")
.Does(() =>
{
foreach(var project in projectToNugetFolderMap.Keys
.Where(p => p.Contains(signed))
) {
var sourceDir = srcDir + Directory(projectName + "." + project) + Directory("bin") + Directory(configuration);
foreach(var targetFolder in projectToNugetFolderMap[project]) {
var destDir = buildDir + Directory("lib");
Information("Copying {0} -> {1}.", sourceDir, destDir);
CopyDirectory(sourceDir, destDir);
}
}
CopyFile(nuspecSrcFile, nuspecSignedDestFile);
var replacedFiles = ReplaceRegexInFiles(nuspecSignedDestFile, "dependency id=\"(Polly\\S*)\"", "dependency id=\"$1-Signed\"");
if (!replacedFiles.Any())
{
throw new Exception("Could not set Polly dependency to Polly-Signed, for -Signed nuget package.");
}
});

Task("__CreateNonSignedNugetPackage")
.Does(() =>
{
var nugetVersion = gitVersionOutput["NuGetVersion"].ToString();
var packageName = projectName;
Information("Building {0}.{1}.nupkg", packageName, nugetVersion);
var nuGetPackSettings = new NuGetPackSettings {
Id = packageName,
Title = packageName,
Version = nugetVersion,
OutputDirectory = nupkgDestDir
};
NuGetPack(nuspecDestFile, nuGetPackSettings);
});

Task("__StronglySignAssemblies")
.Does(() =>
{
Expand All @@ -290,8 +254,7 @@ Task("__StronglySignAssemblies")
Task("__CreateSignedNugetPackage")
.Does(() =>
{
var nugetVersion = gitVersionOutput["NuGetVersion"].ToString();
var packageName = projectName + signed;
var packageName = projectName;
Information("Building {0}.{1}.nupkg", packageName, nugetVersion);
Expand All @@ -302,10 +265,9 @@ Task("__CreateSignedNugetPackage")
OutputDirectory = nupkgDestDir
};
NuGetPack(nuspecSignedDestFile, nuGetPackSettings);
NuGetPack(nuspecDestFile, nuGetPackSettings);
});


//////////////////////////////////////////////////////////////////////
// BUILD TASKS
//////////////////////////////////////////////////////////////////////
Expand All @@ -318,10 +280,7 @@ Task("Build")
.IsDependentOn("__UpdateAppVeyorBuildNumber")
.IsDependentOn("__BuildSolutions")
.IsDependentOn("__RunTests")
.IsDependentOn("__RunDotnetTests")
.IsDependentOn("__CopyNonSignedOutputToNugetFolder")
.IsDependentOn("__CreateNonSignedNugetPackage")
.IsDependentOn("__CopySignedOutputToNugetFolder")
.IsDependentOn("__CopyOutputToNugetFolder")
.IsDependentOn("__StronglySignAssemblies")
.IsDependentOn("__CreateSignedNugetPackage");

Expand Down
4 changes: 2 additions & 2 deletions src/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Reflection;

[assembly: AssemblyProduct("Polly.Caching.MemoryCache")]
[assembly: AssemblyProduct("Polly.Caching.Memory")]
[assembly: AssemblyCompany("App vNext")]
[assembly: AssemblyDescription("Polly.Caching.MemoryCache is a MemoryCache plug-in for the Polly CachePolicy. Polly is a library that allows developers to express resilience and transient fault handling policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner.")]
[assembly: AssemblyDescription("Polly.Caching.Memory is a MemoryCache plug-in for the Polly CachePolicy. Polly is a library that allows developers to express resilience and transient fault handling policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner.")]
[assembly: AssemblyCopyright("Copyright (c) 2018, App vNext")]

#if DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="Polly" Version="5.9.0" />

</ItemGroup>
<ItemGroup>
Expand All @@ -28,7 +27,7 @@
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Polly.Caching.MemoryCache.NetStandard13\Polly.Caching.MemoryCache.NetStandard13.csproj" />
<ProjectReference Include="..\Polly.Caching.Memory.NetStandard13\Polly.Caching.Memory.NetStandard13.csproj" />
</ItemGroup>
<Import Project="..\Polly.Caching.MemoryCache.SharedSpecs\Polly.Caching.MemoryCache.SharedSpecs.projitems" Label="Shared" />
<Import Project="..\Polly.Caching.Memory.SharedSpecs\Polly.Caching.Memory.SharedSpecs.projitems" Label="Shared" />
</Project>
Loading

2 comments on commit bd19386

@dweggemans
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joelhulen is this release planned yet? I'm running into some version conflicts and have to upgrade to Polly 6.0.1, but I currently cannot with MemoryCache version 1.1.0

@joelhulen
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dweggemans This has been released for 19 days now: https://www.nuget.org/packages/Polly.Caching.Memory

The name of the NuGet package had changed with this version to standardize naming across several extension packages. The NuGet package page says as much, but that's probably not clear when viewing through the NuGet Package Manager.

Please sign in to comment.