Caching done right

This commit is contained in:
Bertrand Le Roy
2013-10-09 11:52:07 -07:00
parent 5166c16c73
commit 7abd20f9ec
2 changed files with 21 additions and 3 deletions

View File

@@ -3,6 +3,14 @@ using Orchard.ContentManagement;
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
namespace Orchard.SecureSocketsLayer.Models {
internal class SslSettings {
public string Urls { get; set; }
public bool SecureEverything { get; set; }
public bool CustomEnabled { get; set; }
public string SecureHostName { get; set; }
public string InsecureHostName { get; set; }
}
public class SslSettingsPart : ContentPart {
public string Urls
{

View File

@@ -150,7 +150,7 @@ namespace Orchard.SecureSocketsLayer.Services {
return requestContext;
}
private static bool IsRequestProtected(string path, string appPath, SslSettingsPart settings) {
private static bool IsRequestProtected(string path, string appPath, SslSettings settings) {
var match = false;
var sr = new StringReader(settings.Urls ?? "");
string pattern;
@@ -183,8 +183,18 @@ namespace Orchard.SecureSocketsLayer.Services {
: string.Equals(requestPath, pattern, StringComparison.OrdinalIgnoreCase);
}
private SslSettingsPart GetSettings() {
return _cacheManager.Get("SslSettings", ctx => _workContextAccessor.GetContext().CurrentSite.As<SslSettingsPart>());
private SslSettings GetSettings() {
return _cacheManager.Get("SslSettings",
ctx => {
var settingsPart = _workContextAccessor.GetContext().CurrentSite.As<SslSettingsPart>();
return new SslSettings {
Urls = settingsPart.Urls,
CustomEnabled = settingsPart.CustomEnabled,
SecureEverything = settingsPart.SecureEverything,
SecureHostName = settingsPart.SecureHostName,
InsecureHostName = settingsPart.InsecureHostName
};
});
}
private string MakeInsecure(string path) {