Merge remote-tracking branch 'remotes/Laser.Orchard/feature/5790_partecipate_in_cache_key_generation' into 1.10.x

This commit is contained in:
HermesSbicego-Laser 2016-10-19 16:32:13 +02:00
commit b7ee130847
4 changed files with 40 additions and 3 deletions

View File

@ -41,6 +41,7 @@ namespace Orchard.OutputCache.Filters {
private readonly ICacheService _cacheService;
private readonly ISignals _signals;
private readonly ShellSettings _shellSettings;
private readonly ICachingEventHandler _chachingEvents;
private bool _isDisposed = false;
public ILogger Logger { get; set; }
@ -55,7 +56,8 @@ namespace Orchard.OutputCache.Filters {
IClock clock,
ICacheService cacheService,
ISignals signals,
ShellSettings shellSettings) {
ShellSettings shellSettings,
ICachingEventHandler chachingEvents) {
_cacheManager = cacheManager;
_cacheStorageProvider = cacheStorageProvider;
@ -67,6 +69,7 @@ namespace Orchard.OutputCache.Filters {
_cacheService = cacheService;
_signals = signals;
_shellSettings = shellSettings;
_chachingEvents = chachingEvents;
Logger = NullLogger.Instance;
}
@ -616,6 +619,14 @@ namespace Orchard.OutputCache.Filters {
}
}
//make CacheKey morphable by external modules
try {
keyBuilder = _chachingEvents.ParticipateInCacheKey(keyBuilder);
} catch (UnauthorizedAccessException ex) {
throw new UnauthorizedAccessException();
} catch { }
return keyBuilder.ToString();
}

View File

@ -0,0 +1,12 @@
using Orchard.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
namespace Orchard.OutputCache {
public interface ICachingEventHandler : IEventHandler {
StringBuilder ParticipateInCacheKey(StringBuilder key);
}
}

View File

@ -103,6 +103,7 @@
<Content Include="Web.config" />
<Content Include="Scripts\Web.config" />
<Content Include="Styles\Web.config" />
<Compile Include="ICachingEventHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="Module.txt" />
</ItemGroup>

View File

@ -80,12 +80,25 @@ namespace Orchard.Data.Migration {
/// <summary>
/// This ensures that the framework migrations have run for the distributed locking feature, as existing Orchard installations will not have the required tables when upgrading.
/// </summary>
private void EnsureDistributedLockSchemaExists() {
private void EnsureDistributedLockSchemaExists()
{
// Ensure the distributed lock record schema exists.
var schemaBuilder = new SchemaBuilder(_dataMigrationInterpreter);
var distributedLockSchemaBuilder = new DistributedLockSchemaBuilder(_shellSettings, schemaBuilder);
if (distributedLockSchemaBuilder.EnsureSchema())
if (!distributedLockSchemaBuilder.SchemaExists())
{
// Workaround to avoid some Transaction issue for PostgreSQL.
if (_shellSettings.DataProvider.Equals("PostgreSql", StringComparison.OrdinalIgnoreCase))
{
_transactionManager.RequireNew();
distributedLockSchemaBuilder.CreateSchema();
return;
}
distributedLockSchemaBuilder.CreateSchema();
_transactionManager.RequireNew();
}
}
}
}