internal HttpCachePolicy(CachingProfile profile) { if (profile.Duration.Ticks > 0) { this.SetMaxAge(profile.Duration); } switch (profile.Location) { case CacheLocation.Client: this.SetCacheability(HttpCacheability.Private); break; case CacheLocation.Downstream: this.SetCacheability(HttpCacheability.Public); break; case CacheLocation.None: this.SetCacheability(HttpCacheability.NoCache); break; } }
public void MergeCachingProfile(IDictionary <string, CacheServerConfig> cachesInfo) { Dictionary <string, Topology> topologyInfo = new Dictionary <string, Topology>(); CachingProfile cachingTopologies = new CachingProfile(); if (cachesInfo != null && cachesInfo.Count > 0) { foreach (var cacheInfo in cachesInfo) { string topology = string.Empty; int clusterSize = 1; Topology cacheTopology; if (cacheInfo.Value.CacheSettings != null) { topology = cacheInfo.Value.CacheSettings.CacheTopology.Topology; } if (cacheInfo.Value.CacheDeployment != null) { clusterSize = cacheInfo.Value.CacheDeployment.Servers.ServerNodeList.Length; } if (topologyInfo.ContainsKey(topology)) { cacheTopology = topologyInfo[topology]; if (clusterSize > cacheTopology.MaxClusterSize) { cacheTopology.MaxClusterSize = clusterSize; } cacheTopology.NoOfCaches++; topologyInfo[topology] = cacheTopology; } else { cacheTopology = new Topology { Name = topology, MaxClusterSize = clusterSize, NoOfCaches = 1 }; topologyInfo.Add(topology, cacheTopology); } } } if (_configuration != null && _configuration.Profile != null && _configuration.Profile.CachingProfile != null && _configuration.Profile.CachingProfile.Topologies != null) { Topology[] configTopologies = _configuration.Profile.CachingProfile.Topologies; foreach (Topology configTopology in configTopologies) { if (!topologyInfo.ContainsKey(configTopology.Name)) { topologyInfo.Add(configTopology.Name, configTopology); } } } cachingTopologies.Topologies = topologyInfo.Values.ToArray(); if (_finalConfiguration != null && _finalConfiguration.Profile == null) { _finalConfiguration.Profile = new Profile(); } if (_finalConfiguration != null && _finalConfiguration.Profile != null) { _finalConfiguration.Profile.CachingProfile = cachingTopologies; } }