Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Strathweb.CacheOutput.Azure.sln
Original file line number Diff line number Diff line change
@@ -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}"
Expand All @@ -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
Expand All @@ -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
Expand Down
63 changes: 63 additions & 0 deletions Strathweb.CacheOutput.WebApi2.Azure/AzureCachingProvider.cs
Original file line number Diff line number Diff line change
@@ -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<T>(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);
}
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8" ?>
<PerformanceCounters>
<Category CategoryName="Windows Azure Caching:Client" CategoryHelp="Performance counters for caching clients">
<Counter Name="Requests" Type="NumberOfItems64" HelpString="TotalRequestsHelp"/>
<Counter Name="Requests / sec" Type="RateOfCountsPerSecond32" HelpString="TotalRequestPerSecHelp"/>
<Counter Name="Server Responses Dropped / sec" Type="RateOfCountsPerSecond32" HelpString="TotalServerResponsesDroppedHelp"/>
<Counter Name="Failure Exceptions" Type="NumberOfItems64" HelpString="TotalFailureExceptionsHelp"/>
<Counter Name="Failure Exceptions / sec" Type="RateOfCountsPerSecond32" HelpString="FailureExceptionRateHelp"/>
<Counter Name="Total Local Cache Hits" Type="NumberOfItems64" HelpString="TotalLocalCacheHitsHelp"/>
<Counter Name="Total Local Cache Objects" Type="NumberOfItems64" HelpString="TotalItemsInLocalCacheHelp"/>
<Counter Name="Average Get Latency (Network) / operation Microsecond" Type="AverageCount64" HelpString="AverageCacheGetNetworkLatencyHelp"/>
<Counter Name="Average Get Latency (Network) / operation Microsecond Base" Type="AverageBase" HelpString="AverageCacheGetNetworkLatencyBaseHelp"/>
<Counter Name="Read Requests" Type="NumberOfItems64" HelpString="ReadRequestsHelp"/>
<Counter Name="Write Requests" Type="NumberOfItems64" HelpString="WriteRequestsHelp"/>
<Counter Name="Bytes Received / sec" Type="RateOfCountsPerSecond32" HelpString="CacheIncomingDataRateHelp"/>
<Counter Name="Bytes Sent / sec" Type="RateOfCountsPerSecond32" HelpString="CacheOutgoingDateRateHelp"/>
<Counter Name="Average Get Latency / operation Microsecond" Type="AverageCount64" HelpString="AverageCacheGetLatencyHelp"/>
<Counter Name="Average Get Latency / operation Microsecond Base" Type="AverageBase" HelpString="AverageCacheGetLatencyBaseHelp"/>
<Counter Name="Average Put Latency / operation Microsecond" Type="AverageCount64" HelpString="AverageCachePutLatencyHelp"/>
<Counter Name="Average Put Latency / operation Microsecond Base" Type="AverageBase" HelpString="AverageCachePutLatencyBaseHelp"/>
<Counter Name="Local Cache Filled Percentage" Type="RawFraction" HelpString="PercentageLocalCacheFullHelp"/>
<Counter Name="Local Cache Filled Percentage Base" Type="RawBase" HelpString="PercentageLocalCacheFullBaseHelp"/>
<Counter Name="Local Cache Hits Percentage" Type="RawFraction" HelpString="PercentageLocalCacheHitsHelp"/>
<Counter Name="Local Cache Hits Percentage Base" Type="RawBase" HelpString="PercentageLocalCacheHitsBaseHelp"/>
<Counter Name="Total Notifications Received" Type="NumberOfItems64" HelpString="TotalNotificationsReceivedHelp"/>
<Counter Name="Retry Exceptions" Type="NumberOfItems64" HelpString="TotalRetryExceptionsHelp"/>
<Counter Name="Retry Exceptions / sec" Type="RateOfCountsPerSecond32" HelpString="RetryExceptionRateHelp"/>
<Counter Name="Timeout Exceptions" Type="NumberOfItems64" HelpString="TotalTimeoutExceptionsHelp"/>
<Counter Name="Timeout Exceptions / sec" Type="RateOfCountsPerSecond32" HelpString="TimeoutExceptionRateHelp"/>
<Counter Name="Current Server Connections" Type="NumberOfItems64" HelpString="TotalActiveServerConnectionsHelp"/>
<Counter Name="Total Connection Requests Failed" Type="NumberOfItems64" HelpString="TotalConnectionRequestsFailedHelp"/>
<Counter Name="Network Exceptions" Type="NumberOfItems64" HelpString="TotalNetworkExceptionsHelp"/>
<Counter Name="Network Exceptions / sec" Type="RateOfCountsPerSecond32" HelpString="NetworkExceptionRateHelp"/>
<Counter Name="Current Waiting Requests" Type="NumberOfItems64" HelpString="TotalOutstandingRequestsHelp" />
</Category>
</PerformanceCounters>
36 changes: 36 additions & 0 deletions Strathweb.CacheOutput.WebApi2.Azure/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.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')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{421ED792-6DCB-46CD-87CE-36AA56619732}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Strathweb.CacheOutput.WebApi2.Azure</RootNamespace>
<AssemblyName>Strathweb.CacheOutput.WebApi2.Azure</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</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>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="AzureCachingProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Microsoft.WindowsAzure.Caching\ClientPerfCountersInstaller.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Microsoft.WindowsAzure.Caching\PerformanceCounters.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Microsoft.WindowsAzure.Caching\ClientPerfCountersInstaller.exe.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.ApplicationServer.Caching.AzureClientHelper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.WindowsAzure.Caching.2.1.0.0\lib\net40-full\Microsoft.ApplicationServer.Caching.AzureClientHelper.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationServer.Caching.AzureCommon, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.WindowsAzure.Caching.2.1.0.0\lib\net40-full\Microsoft.ApplicationServer.Caching.AzureCommon.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationServer.Caching.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.WindowsAzure.Caching.2.1.0.0\lib\net40-full\Microsoft.ApplicationServer.Caching.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.WindowsAzure.Caching.2.1.0.0\lib\net40-full\Microsoft.ApplicationServer.Caching.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.DistributedCache, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.WindowsAzure.Caching.2.1.0.0\lib\net40-full\Microsoft.Web.DistributedCache.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsFabric.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.WindowsAzure.Caching.2.1.0.0\lib\net40-full\Microsoft.WindowsFabric.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsFabric.Data.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.WindowsAzure.Caching.2.1.0.0\lib\net40-full\Microsoft.WindowsFabric.Data.Common.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Formatting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.0.0\lib\net45\System.Net.Http.Formatting.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.0.0\lib\net45\System.Web.Http.dll</HintPath>
</Reference>
<Reference Include="WebApi.OutputCache.Core">
<HintPath>..\packages\Strathweb.CacheOutput.WebApi2.0.5\lib\net45\WebApi.OutputCache.Core.dll</HintPath>
</Reference>
<Reference Include="WebApi.OutputCache.V2">
<HintPath>..\packages\Strathweb.CacheOutput.WebApi2.0.5\lib\net45\WebApi.OutputCache.V2.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- 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>
29 changes: 29 additions & 0 deletions Strathweb.CacheOutput.WebApi2.Azure/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="dataCacheClients" type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core" allowLocation="true" allowDefinition="Everywhere" />
<section name="cacheDiagnostics" type="Microsoft.ApplicationServer.Caching.AzureCommon.DiagnosticsConfigurationSection, Microsoft.ApplicationServer.Caching.AzureCommon" allowLocation="true" allowDefinition="Everywhere" />
</configSections>
<dataCacheClients>
<dataCacheClient name="default">
<!--To use the in-role flavor of Windows Azure Caching, set identifier to be the cache cluster role name -->
<!--To use the Windows Azure Caching Service, set identifier to be the endpoint of the cache cluster -->
<!--To use the in-role flavor of Windows Azure Caching, set identifier to be the cache cluster role name -->
<!--To use the Windows Azure Caching Service, set identifier to be the endpoint of the cache cluster -->
<autoDiscover isEnabled="true" identifier="[Cache role name or Service Endpoint]" />

<!--<localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" />-->

<!--Use this section to specify security settings for connecting to your cache. This section is not required if your cache is hosted on a role that is a part of your cloud service. -->
<!--<securityProperties mode="Message" sslEnabled="false">
<messageSecurity authorizationInfo="[Authentication Key]" />
</securityProperties>-->
<!--<localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" />-->
<!--Use this section to specify security settings for connecting to your cache. This section is not required if your cache is hosted on a role that is a part of your cloud service. -->
<!--<securityProperties mode="Message" sslEnabled="false">
<messageSecurity authorizationInfo="[Authentication Key]" />
</securityProperties>-->
</dataCacheClient>
</dataCacheClients>

</configuration>
8 changes: 8 additions & 0 deletions Strathweb.CacheOutput.WebApi2.Azure/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Caching" version="2.1.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net45" />
<package id="Strathweb.CacheOutput.WebApi2" version="0.5" targetFramework="net45" />
</packages>