diff --git a/src/Orchard.Web/Modules/Orchard.Azure/Orchard.Azure.csproj b/src/Orchard.Web/Modules/Orchard.Azure/Orchard.Azure.csproj
index a37eca615..b92f1bb98 100644
--- a/src/Orchard.Web/Modules/Orchard.Azure/Orchard.Azure.csproj
+++ b/src/Orchard.Web/Modules/Orchard.Azure/Orchard.Azure.csproj
@@ -130,7 +130,6 @@
-
diff --git a/src/Orchard.Web/Modules/Orchard.Azure/Services/Caching/Output/AzureOutputCacheStorageProvider.cs b/src/Orchard.Web/Modules/Orchard.Azure/Services/Caching/Output/AzureOutputCacheStorageProvider.cs
index bf994e216..27adc02d9 100644
--- a/src/Orchard.Web/Modules/Orchard.Azure/Services/Caching/Output/AzureOutputCacheStorageProvider.cs
+++ b/src/Orchard.Web/Modules/Orchard.Azure/Services/Caching/Output/AzureOutputCacheStorageProvider.cs
@@ -4,6 +4,7 @@ using System.Globalization;
using System.Linq;
using Microsoft.ApplicationServer.Caching;
using Orchard.Azure.Services.Environment.Configuration;
+using Orchard.Caching;
using Orchard.Environment.Configuration;
using Orchard.Environment.Extensions;
using Orchard.Logging;
@@ -15,11 +16,25 @@ namespace Orchard.Azure.Services.Caching.Output {
[OrchardFeature(Constants.OutputCacheFeatureName)]
[OrchardSuppressDependency("Orchard.OutputCache.Services.DefaultCacheStorageProvider")]
public class AzureOutputCacheStorageProvider : Component, IOutputCacheStorageProvider {
+ public const string DataCacheKey = "DataCache";
+ public const string ClientConfigurationKey = "CacheClientConfiguration";
+ public const int Retries = 2;
- private readonly DataCache _cache;
private readonly string _regionAlphaNumeric;
+ private readonly ICacheManager _cacheManager;
+ private readonly ShellSettings _shellSettings;
+ private readonly IPlatformConfigurationAccessor _pca;
+ private readonly ISignals _signals;
- public AzureOutputCacheStorageProvider(ShellSettings shellSettings, IAzureOutputCacheHolder cacheHolder, IPlatformConfigurationAccessor pca) {
+ public AzureOutputCacheStorageProvider(
+ ShellSettings shellSettings,
+ IPlatformConfigurationAccessor pca,
+ ICacheManager cacheManager,
+ ISignals signals) {
+ _cacheManager = cacheManager;
+ _shellSettings = shellSettings;
+ _pca = pca;
+ _signals = signals;
var region = shellSettings.Name;
@@ -29,64 +44,117 @@ namespace Orchard.Azure.Services.Caching.Output {
// of two distinct original region strings yielding the same transformed region string.
_regionAlphaNumeric = new String(Array.FindAll(region.ToCharArray(), Char.IsLetterOrDigit)) + region.GetHashCode().ToString(CultureInfo.InvariantCulture);
- _cache = cacheHolder.TryGetDataCache(() => {
- CacheClientConfiguration cacheConfig;
-
- try {
- cacheConfig = CacheClientConfiguration.FromPlatformConfiguration(shellSettings.Name, Constants.OutputCacheSettingNamePrefix, pca);
- cacheConfig.Validate();
- }
- catch (Exception ex) {
- throw new Exception(String.Format("The {0} configuration settings are missing or invalid.", Constants.OutputCacheFeatureName), ex);
- }
-
- var cache = cacheConfig.CreateCache();
- cache.CreateRegion(_regionAlphaNumeric);
-
- return cache;
- });
+ Logger = NullLogger.Instance;
}
+ public ILogger Logger { get; set; }
+
+ public CacheClientConfiguration CacheConfiguration {
+ get {
+ return _cacheManager.Get(ClientConfigurationKey, ctx => {
+ CacheClientConfiguration cacheConfig ;
+ try {
+ cacheConfig = CacheClientConfiguration.FromPlatformConfiguration(
+ _shellSettings.Name,
+ Constants.OutputCacheSettingNamePrefix,
+ _pca);
+
+ cacheConfig.Validate();
+ return cacheConfig;
+ }
+ catch (Exception ex) {
+ throw new Exception(String.Format("The {0} configuration settings are missing or invalid.", Constants.OutputCacheFeatureName), ex);
+ }
+ });
+ }
+ }
+
+ public DataCache Cache {
+ get {
+ return _cacheManager.Get(DataCacheKey, ctx => {
+ ctx.Monitor(_signals.When(DataCacheKey));
+ var cache = CacheConfiguration.CreateCache();
+ cache.CreateRegion(_regionAlphaNumeric);
+
+ return cache;
+ });
+ }
+ }
+
+ public T SafeCall(Func function) {
+ return Retry(function, Retries);
+ }
+
+ public void SafeCall(Action function) {
+ Retry