mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Shifting CacheSettingsPart
This commit is contained in:
@@ -3,7 +3,6 @@ using Orchard.OutputCache.Models;
|
|||||||
using Orchard.OutputCache.Services;
|
using Orchard.OutputCache.Services;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.Core.Common.Models;
|
using Orchard.Core.Common.Models;
|
||||||
using Orchard.Data;
|
|
||||||
using Orchard.ContentManagement.Handlers;
|
using Orchard.ContentManagement.Handlers;
|
||||||
|
|
||||||
namespace Orchard.OutputCache.Handlers {
|
namespace Orchard.OutputCache.Handlers {
|
||||||
@@ -11,11 +10,9 @@ namespace Orchard.OutputCache.Handlers {
|
|||||||
private readonly ICacheService _cacheService;
|
private readonly ICacheService _cacheService;
|
||||||
|
|
||||||
public CacheSettingsPartHandler(
|
public CacheSettingsPartHandler(
|
||||||
IRepository<CacheSettingsPartRecord> repository,
|
|
||||||
ICacheService cacheService) {
|
ICacheService cacheService) {
|
||||||
_cacheService = cacheService;
|
_cacheService = cacheService;
|
||||||
Filters.Add(new ActivatingFilter<CacheSettingsPart>("Site"));
|
Filters.Add(new ActivatingFilter<CacheSettingsPart>("Site"));
|
||||||
Filters.Add(StorageFilter.For(repository));
|
|
||||||
|
|
||||||
// initializing default cache settings values
|
// initializing default cache settings values
|
||||||
OnInitializing<CacheSettingsPart>((context, part) => { part.DefaultCacheDuration = 300; });
|
OnInitializing<CacheSettingsPart>((context, part) => { part.DefaultCacheDuration = 300; });
|
||||||
|
@@ -3,19 +3,7 @@
|
|||||||
namespace Orchard.OutputCache {
|
namespace Orchard.OutputCache {
|
||||||
public class Migrations : DataMigrationImpl {
|
public class Migrations : DataMigrationImpl {
|
||||||
public int Create() {
|
public int Create() {
|
||||||
|
|
||||||
SchemaBuilder.CreateTable("CacheSettingsPartRecord",
|
|
||||||
table => table
|
|
||||||
.ContentPartRecord()
|
|
||||||
.Column<int>("DefaultCacheDuration")
|
|
||||||
.Column<int>("DefaultMaxAge")
|
|
||||||
.Column<string>("IgnoredUrls", c => c.Unlimited())
|
|
||||||
.Column<string>("VaryQueryStringParameters", c => c.Unlimited())
|
|
||||||
.Column<string>("VaryRequestHeaders", c => c.Unlimited())
|
|
||||||
.Column<bool>("DebugMode", c => c.WithDefault(false))
|
|
||||||
.Column<bool>("ApplyCulture", c => c.WithDefault(false))
|
|
||||||
);
|
|
||||||
|
|
||||||
SchemaBuilder.CreateTable("CacheParameterRecord",
|
SchemaBuilder.CreateTable("CacheParameterRecord",
|
||||||
table => table
|
table => table
|
||||||
.Column<int>("Id", c => c.PrimaryKey().Identity())
|
.Column<int>("Id", c => c.PrimaryKey().Identity())
|
||||||
|
@@ -1,42 +1,42 @@
|
|||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
|
|
||||||
namespace Orchard.OutputCache.Models {
|
namespace Orchard.OutputCache.Models {
|
||||||
public class CacheSettingsPart : ContentPart<CacheSettingsPartRecord> {
|
public class CacheSettingsPart : ContentPart {
|
||||||
public const string CacheKey = "CacheSettingsPart";
|
public const string CacheKey = "CacheSettingsPart";
|
||||||
|
|
||||||
public int DefaultCacheDuration {
|
public int DefaultCacheDuration {
|
||||||
get { return Record.DefaultCacheDuration; }
|
get { return this.Retrieve(x => x.DefaultCacheDuration); }
|
||||||
set { Record.DefaultCacheDuration = value; }
|
set { this.Store(x => x.DefaultCacheDuration, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public int DefaultMaxAge {
|
public int DefaultMaxAge {
|
||||||
get { return Record.DefaultMaxAge; }
|
get { return this.Retrieve(x => x.DefaultMaxAge); }
|
||||||
set { Record.DefaultMaxAge = value; }
|
set { this.Store(x => x.DefaultMaxAge, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string VaryQueryStringParameters {
|
public string VaryQueryStringParameters {
|
||||||
get { return Record.VaryQueryStringParameters; }
|
get { return this.Retrieve(x => x.VaryQueryStringParameters); }
|
||||||
set { Record.VaryQueryStringParameters = value; }
|
set { this.Store(x => x.VaryQueryStringParameters, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string VaryRequestHeaders {
|
public string VaryRequestHeaders {
|
||||||
get { return Record.VaryRequestHeaders; }
|
get { return this.Retrieve(x => x.VaryRequestHeaders); }
|
||||||
set { Record.VaryRequestHeaders = value; }
|
set { this.Store(x => x.VaryRequestHeaders, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string IgnoredUrls {
|
public string IgnoredUrls {
|
||||||
get { return Record.IgnoredUrls; }
|
get { return this.Retrieve(x => x.IgnoredUrls); }
|
||||||
set { Record.IgnoredUrls = value; }
|
set { this.Store(x => x.IgnoredUrls, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ApplyCulture {
|
public bool ApplyCulture {
|
||||||
get { return Record.ApplyCulture; }
|
get { return this.Retrieve(x => x.ApplyCulture); }
|
||||||
set { Record.ApplyCulture = value; }
|
set { this.Store(x => x.ApplyCulture, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DebugMode {
|
public bool DebugMode {
|
||||||
get { return Record.DebugMode; }
|
get { return this.Retrieve(x => x.DebugMode); }
|
||||||
set { Record.DebugMode = value; }
|
set { this.Store(x => x.DebugMode, value); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,20 +0,0 @@
|
|||||||
using Orchard.ContentManagement.Records;
|
|
||||||
using Orchard.Data.Conventions;
|
|
||||||
|
|
||||||
namespace Orchard.OutputCache.Models {
|
|
||||||
public class CacheSettingsPartRecord : ContentPartRecord {
|
|
||||||
public virtual int DefaultCacheDuration { get; set; }
|
|
||||||
public virtual int DefaultMaxAge { get; set; }
|
|
||||||
public virtual bool DebugMode { get; set; }
|
|
||||||
public virtual bool ApplyCulture { get; set; }
|
|
||||||
|
|
||||||
[StringLengthMax]
|
|
||||||
public virtual string VaryQueryStringParameters { get; set; }
|
|
||||||
|
|
||||||
[StringLengthMax]
|
|
||||||
public virtual string VaryRequestHeaders { get; set; }
|
|
||||||
|
|
||||||
[StringLengthMax]
|
|
||||||
public virtual string IgnoredUrls { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@@ -102,7 +102,6 @@
|
|||||||
<Compile Include="Migrations.cs" />
|
<Compile Include="Migrations.cs" />
|
||||||
<Compile Include="Models\CacheItem.cs" />
|
<Compile Include="Models\CacheItem.cs" />
|
||||||
<Compile Include="Models\CacheSettingsPart.cs" />
|
<Compile Include="Models\CacheSettingsPart.cs" />
|
||||||
<Compile Include="Models\CacheSettingsPartRecord.cs" />
|
|
||||||
<Compile Include="Models\CacheParameterRecord.cs" />
|
<Compile Include="Models\CacheParameterRecord.cs" />
|
||||||
<Compile Include="Services\CacheService.cs" />
|
<Compile Include="Services\CacheService.cs" />
|
||||||
<Compile Include="Services\DefaultCacheControlStrategy.cs" />
|
<Compile Include="Services\DefaultCacheControlStrategy.cs" />
|
||||||
|
@@ -106,6 +106,20 @@ namespace Upgrade.Controllers {
|
|||||||
|
|
||||||
_upgradeService.ExecuteReader("DROP TABLE " + _upgradeService.GetPrefixedTableName("Orchard_AntiSpam_TypePadSettingsPartRecord"), null);
|
_upgradeService.ExecuteReader("DROP TABLE " + _upgradeService.GetPrefixedTableName("Orchard_AntiSpam_TypePadSettingsPartRecord"), null);
|
||||||
|
|
||||||
|
// CacheSettingsPartRecord
|
||||||
|
_upgradeService.ExecuteReader("SELECT * FROM " + _upgradeService.GetPrefixedTableName("Orchard_OutputCache_CacheSettingsPartRecord"),
|
||||||
|
(reader, connection) => {
|
||||||
|
site.As<InfosetPart>().Store("CacheSettingsPart", "DefaultCacheDuration", (int)reader["DefaultCacheDuration"]);
|
||||||
|
site.As<InfosetPart>().Store("CacheSettingsPart", "DefaultMaxAge", (int)reader["DefaultMaxAge"]);
|
||||||
|
site.As<InfosetPart>().Store("CacheSettingsPart", "VaryQueryStringParameters", (string)reader["VaryQueryStringParameters"]);
|
||||||
|
site.As<InfosetPart>().Store("CacheSettingsPart", "VaryRequestHeaders", (string)reader["VaryRequestHeaders"]);
|
||||||
|
site.As<InfosetPart>().Store("CacheSettingsPart", "IgnoredUrls", (string)reader["IgnoredUrls"]);
|
||||||
|
site.As<InfosetPart>().Store("CacheSettingsPart", "ApplyCulture", (bool)reader["ApplyCulture"]);
|
||||||
|
site.As<InfosetPart>().Store("CacheSettingsPart", "DebugMode", (bool)reader["DebugMode"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
_upgradeService.ExecuteReader("DROP TABLE " + _upgradeService.GetPrefixedTableName("Orchard_OutputCache_CacheSettingsPartRecord"), null);
|
||||||
|
|
||||||
|
|
||||||
_orchardServices.Notifier.Information(T("Site Settings migrated successfully"));
|
_orchardServices.Notifier.Information(T("Site Settings migrated successfully"));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user