public override void OnActionExecuting(ActionExecutingContext context) { string profile = this.ProfileName; if (!string.IsNullOrWhiteSpace(profile)) { this.CacheProfile = string.Empty; string tenant = DbConvention.GetTenant(); var config = CacheConfig.Get(tenant, profile); if (config != null) { this.Duration = config.Duration; this.Location = config.Location; this.NoStore = config.NoStore; this.SqlDependency = config.SqlDependency; this.VaryByContentEncoding = config.VaryByContentEncoding; this.VaryByCustom = config.VaryByCustom; this.VaryByHeader = config.VaryByHeader; this.VaryByParam = config.VaryByParam; } } base.OnActionExecuting(context); }
private void Initialize() { string profile = this.ProfileName; if (string.IsNullOrWhiteSpace(profile)) { return; } string tenant = TenantConvention.GetTenant(); var config = CacheConfig.Get(tenant, profile); if (config == null) { return; } this.Duration = config.Duration; this.Location = config.Location; this.NoStore = config.NoStore; this.VaryByCustom = config.VaryByCustom; }
private CacheSettings GetCacheSettings() { Log.Verbose("Getting cache settings by tenant based profile."); var settings = new CacheSettings { Duration = this.Duration, Location = this.Location, NoStore = this.NoStore, Options = this.Options, VaryByCustom = this.VaryByCustom, VaryByParam = this.VaryByParam }; if (this.Duration > 0) { settings.IsCachingEnabled = true; } string profile = this.ProfileName; if (string.IsNullOrWhiteSpace(profile)) { Log.Verbose("Aborted creating cache settings because the current cache profile name is empty."); return(settings); } Log.Verbose("Setting the \"CacheProfile\" to an empty value to override the behavior of DonutCache."); this.CacheProfile = string.Empty; string tenant = TenantConvention.GetTenant(); Log.Verbose("The current tenant is {tenant}.", tenant); Log.Verbose("Getting cache config for current tenant \"{tenant}\" and profile \"{profile}\".", tenant, profile); var config = CacheConfig.Get(tenant, profile); if (config == null) { Log.Verbose("Could not find any cache config information for current tenant \"{tenant}\" and profile \"{profile}\".", tenant, profile); return(settings); } Log.Verbose("The cache duration for tenant \"{tenant}\" and profile \"{profile}\" is {Duration}", tenant, profile, config.Duration); settings.Duration = config.Duration; Log.Verbose("The cache location for tenant \"{tenant}\" and profile \"{profile}\" is {Location}", tenant, profile, config.Location); settings.Location = config.Location; Log.Verbose("The cache NoStore value for tenant \"{tenant}\" and profile \"{profile}\" is {NoStore}", tenant, profile, config.NoStore); settings.NoStore = config.NoStore; Log.Verbose("The cache VaryByCustom value for tenant \"{tenant}\" and profile \"{profile}\" is {VaryByCustom}", tenant, profile, config.VaryByCustom); settings.VaryByCustom = config.VaryByCustom; Log.Verbose("The cache VaryByParam value for tenant \"{tenant}\" and profile \"{profile}\" is {VaryByParam}", tenant, profile, config.VaryByParam); settings.VaryByParam = config.VaryByParam; Log.Verbose("The cache Options value for tenant \"{tenant}\" and profile \"{profile}\" is {Options}", tenant, profile, config.Options); settings.Options = config.Options; settings.IsCachingEnabled = settings.Duration > 0; return(settings); }