diff --git a/Strathweb.CacheOutput.Azure.sln b/Strathweb.CacheOutput.Azure.sln index 72aa4b3..dd2ad69 100644 --- a/Strathweb.CacheOutput.Azure.sln +++ b/Strathweb.CacheOutput.Azure.sln @@ -1,6 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30110.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Strathweb.CacheOutput.Azure", "Strathweb.CacheOutput.Azure\Strathweb.CacheOutput.Azure.csproj", "{39A3B3A4-4093-435C-B987-77B5B8B6336F}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{5504326F-F545-4EBE-9B7D-CED34338A414}" @@ -10,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{550432 .nuget\NuGet.targets = .nuget\NuGet.targets EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Strathweb.CacheOutput.WebApi2.Azure", "Strathweb.CacheOutput.WebApi2.Azure\Strathweb.CacheOutput.WebApi2.Azure.csproj", "{421ED792-6DCB-46CD-87CE-36AA56619732}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -20,6 +24,10 @@ Global {39A3B3A4-4093-435C-B987-77B5B8B6336F}.Debug|Any CPU.Build.0 = Debug|Any CPU {39A3B3A4-4093-435C-B987-77B5B8B6336F}.Release|Any CPU.ActiveCfg = Release|Any CPU {39A3B3A4-4093-435C-B987-77B5B8B6336F}.Release|Any CPU.Build.0 = Release|Any CPU + {421ED792-6DCB-46CD-87CE-36AA56619732}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {421ED792-6DCB-46CD-87CE-36AA56619732}.Debug|Any CPU.Build.0 = Debug|Any CPU + {421ED792-6DCB-46CD-87CE-36AA56619732}.Release|Any CPU.ActiveCfg = Release|Any CPU + {421ED792-6DCB-46CD-87CE-36AA56619732}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Strathweb.CacheOutput.WebApi2.Azure/AzureCachingProvider.cs b/Strathweb.CacheOutput.WebApi2.Azure/AzureCachingProvider.cs new file mode 100644 index 0000000..83a3b04 --- /dev/null +++ b/Strathweb.CacheOutput.WebApi2.Azure/AzureCachingProvider.cs @@ -0,0 +1,63 @@ +using System; +using Microsoft.ApplicationServer.Caching; +using WebApi.OutputCache.Core.Cache; + +namespace Strathweb.CacheOutput.WebApi2.Azure +{ + public class AzureCachingProvider : IApiOutputCache + { + private readonly DataCache _cache; + private const string Region = "GlobalRegion"; + + public AzureCachingProvider() + { + _cache = new DataCache(); + _cache.CreateRegion(Region); + } + + public void RemoveStartsWith(string key) + { + var objs = _cache.GetObjectsByTag(new DataCacheTag(key), Region); + foreach (var o in objs) + { + _cache.Remove(o.Key, Region); + } + } + + public T Get(string key) where T : class + { + var result = _cache.Get(key, Region) as T; + return result; + } + + public object Get(string key) + { + var result = _cache.Get(key, Region); + return result; + } + + public void Remove(string key) + { + _cache.Remove(key, Region); + } + + public bool Contains(string key) + { + var result = _cache.Get(key, Region); + if (result != null) return true; + + return false; + } + + public void Add(string key, object o, DateTimeOffset expiration, string dependsOnKey = null) + { + var exp = expiration - DateTime.Now; + if (dependsOnKey == null) + { + dependsOnKey = key; + } + + _cache.Put(key, o, exp, new[] { new DataCacheTag(dependsOnKey) }, Region); + } + } +} diff --git a/Strathweb.CacheOutput.WebApi2.Azure/Microsoft.WindowsAzure.Caching/ClientPerfCountersInstaller.exe b/Strathweb.CacheOutput.WebApi2.Azure/Microsoft.WindowsAzure.Caching/ClientPerfCountersInstaller.exe new file mode 100644 index 0000000..62ad6a9 Binary files /dev/null and b/Strathweb.CacheOutput.WebApi2.Azure/Microsoft.WindowsAzure.Caching/ClientPerfCountersInstaller.exe differ diff --git a/Strathweb.CacheOutput.WebApi2.Azure/Microsoft.WindowsAzure.Caching/ClientPerfCountersInstaller.exe.config b/Strathweb.CacheOutput.WebApi2.Azure/Microsoft.WindowsAzure.Caching/ClientPerfCountersInstaller.exe.config new file mode 100644 index 0000000..ecf42e1 --- /dev/null +++ b/Strathweb.CacheOutput.WebApi2.Azure/Microsoft.WindowsAzure.Caching/ClientPerfCountersInstaller.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Strathweb.CacheOutput.WebApi2.Azure/Microsoft.WindowsAzure.Caching/PerformanceCounters.xml b/Strathweb.CacheOutput.WebApi2.Azure/Microsoft.WindowsAzure.Caching/PerformanceCounters.xml new file mode 100644 index 0000000..8446904 --- /dev/null +++ b/Strathweb.CacheOutput.WebApi2.Azure/Microsoft.WindowsAzure.Caching/PerformanceCounters.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Strathweb.CacheOutput.WebApi2.Azure/Properties/AssemblyInfo.cs b/Strathweb.CacheOutput.WebApi2.Azure/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..bfdd4e3 --- /dev/null +++ b/Strathweb.CacheOutput.WebApi2.Azure/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Strathweb.CacheOutput.Azure")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Strathweb.CacheOutput.Azure")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0be337b5-b477-4b1d-9700-675b047352d2")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Strathweb.CacheOutput.WebApi2.Azure/Strathweb.CacheOutput.WebApi2.Azure.csproj b/Strathweb.CacheOutput.WebApi2.Azure/Strathweb.CacheOutput.WebApi2.Azure.csproj new file mode 100644 index 0000000..b8a33b5 --- /dev/null +++ b/Strathweb.CacheOutput.WebApi2.Azure/Strathweb.CacheOutput.WebApi2.Azure.csproj @@ -0,0 +1,113 @@ + + + + + Debug + AnyCPU + {421ED792-6DCB-46CD-87CE-36AA56619732} + Library + Properties + Strathweb.CacheOutput.WebApi2.Azure + Strathweb.CacheOutput.WebApi2.Azure + v4.5 + 512 + ..\ + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + Always + + + Always + + + + + + + Always + + + + + False + ..\packages\Microsoft.WindowsAzure.Caching.2.1.0.0\lib\net40-full\Microsoft.ApplicationServer.Caching.AzureClientHelper.dll + + + False + ..\packages\Microsoft.WindowsAzure.Caching.2.1.0.0\lib\net40-full\Microsoft.ApplicationServer.Caching.AzureCommon.dll + + + False + ..\packages\Microsoft.WindowsAzure.Caching.2.1.0.0\lib\net40-full\Microsoft.ApplicationServer.Caching.Client.dll + + + False + ..\packages\Microsoft.WindowsAzure.Caching.2.1.0.0\lib\net40-full\Microsoft.ApplicationServer.Caching.Core.dll + + + False + ..\packages\Microsoft.WindowsAzure.Caching.2.1.0.0\lib\net40-full\Microsoft.Web.DistributedCache.dll + + + False + ..\packages\Microsoft.WindowsAzure.Caching.2.1.0.0\lib\net40-full\Microsoft.WindowsFabric.Common.dll + + + False + ..\packages\Microsoft.WindowsAzure.Caching.2.1.0.0\lib\net40-full\Microsoft.WindowsFabric.Data.Common.dll + + + False + ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll + + + + False + ..\packages\Microsoft.AspNet.WebApi.Client.5.0.0\lib\net45\System.Net.Http.Formatting.dll + + + + + False + ..\packages\Microsoft.AspNet.WebApi.Core.5.0.0\lib\net45\System.Web.Http.dll + + + ..\packages\Strathweb.CacheOutput.WebApi2.0.5\lib\net45\WebApi.OutputCache.Core.dll + + + ..\packages\Strathweb.CacheOutput.WebApi2.0.5\lib\net45\WebApi.OutputCache.V2.dll + + + + + + \ No newline at end of file diff --git a/Strathweb.CacheOutput.WebApi2.Azure/app.config b/Strathweb.CacheOutput.WebApi2.Azure/app.config new file mode 100644 index 0000000..69ffde7 --- /dev/null +++ b/Strathweb.CacheOutput.WebApi2.Azure/app.config @@ -0,0 +1,29 @@ + + + +
+
+ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Strathweb.CacheOutput.WebApi2.Azure/packages.config b/Strathweb.CacheOutput.WebApi2.Azure/packages.config new file mode 100644 index 0000000..1e2e97e --- /dev/null +++ b/Strathweb.CacheOutput.WebApi2.Azure/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file