public PSNamedCachesAttributes(IntrinsicSettings.CacheServiceInput.NamedCache namedCache) { CacheName = namedCache.CacheName; ExpiryPolicy = namedCache.ExpirationSettingsSection.Type; TimeToLiveInMinutes = namedCache.ExpirationSettingsSection.TimeToLiveInMinutes; Eviction = "LeastRecentlyUsed".Equals(namedCache.EvictionPolicy) ? "Enabled" : "Disabled"; Notifications = namedCache.NotificationsEnabled ? "Enabled" : "Disabled"; HighAvailability = namedCache.HighAvailabilityEnabled ? "Enabled" : "Disabled"; }
public void RemoveNamedCache(string cacheServiceName, string namedCacheName, Action <bool, string, string, string, Action> ConfirmAction, bool force) { if ("default".Equals(namedCacheName)) { throw new ArgumentException(string.Format(Properties.Resources.DoNotRemoveDefaultNamedCache)); } string cloudServiceName = null; CloudServiceResource cacheResource = FetchCloudServiceResource(cacheServiceName, out cloudServiceName); bool namedCacheFound = false; IntrinsicSettings.CacheServiceInput.NamedCache removeNamedCache = null; foreach (IntrinsicSettings.CacheServiceInput.NamedCache namedCache in cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches) { if (namedCache.CacheName.Equals(namedCacheName)) { removeNamedCache = namedCache; namedCacheFound = true; break; } } if (!namedCacheFound) { throw new ArgumentException(string.Format(Properties.Resources.NamedCacheDoNotExists, cacheServiceName, namedCacheName)); } ConfirmAction( force, Properties.Resources.RemoveNamedCacheWarning, Properties.Resources.RemovingNamedCache, cacheServiceName, () => { CacheServiceCreateParameters param = new CacheServiceCreateParameters(); param.IntrinsicSettingsSection = cacheResource.IntrinsicSettingsSection; param.ETag = cacheResource.ETag; param.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches.Remove(removeNamedCache); cacheResource = ProvisionCacheService(cloudServiceName, cacheResource.Name, param, false); }); }
public CloudServiceResource AddNamedCache(string cacheServiceName, string namedCacheName, string expiryPolicy, int expiryTimeInMinutes, bool noeviction, bool notifications, bool highAvailability) { string cloudServiceName = null; CloudServiceResource cacheResource = FetchCloudServiceResource(cacheServiceName, out cloudServiceName); foreach (IntrinsicSettings.CacheServiceInput.NamedCache namedCache in cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches) { if (namedCache.CacheName.Equals(namedCacheName)) { throw new ArgumentException(string.Format(Properties.Resources.NamedCacheExists, cacheServiceName, namedCacheName)); } } if (cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType == CacheServiceSkuType.Basic) { throw new ArgumentException(Properties.Resources.NoAddInBasicSku); } else if (cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches.Count == MaxNamedCacheCount) { throw new ArgumentException(Properties.Resources.NoAddInAllSku); } IntrinsicSettings.CacheServiceInput.NamedCache newNamedCache = new IntrinsicSettings.CacheServiceInput.NamedCache(); newNamedCache.CacheName = namedCacheName; newNamedCache.EvictionPolicy = noeviction ? "None" : "LeastRecentlyUsed"; newNamedCache.ExpirationSettingsSection = new IntrinsicSettings.CacheServiceInput.NamedCache.ExpirationSettings(); newNamedCache.ExpirationSettingsSection.Type = expiryPolicy; newNamedCache.ExpirationSettingsSection.TimeToLiveInMinutes = expiryTimeInMinutes; newNamedCache.NotificationsEnabled = notifications; newNamedCache.HighAvailabilityEnabled = highAvailability; CacheServiceCreateParameters param = new CacheServiceCreateParameters(); param.IntrinsicSettingsSection = cacheResource.IntrinsicSettingsSection; param.ETag = cacheResource.ETag; param.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches.Add(newNamedCache); cacheResource = ProvisionCacheService(cloudServiceName, cacheResource.Name, param, false); return(cacheResource); }
public CloudServiceResource AddNamedCache(string cacheServiceName, string namedCacheName, string expiryPolicy, int expiryTimeInMinutes, bool noeviction, bool notifications, bool highAvailability) { string cloudServiceName = null; CloudServiceResource cacheResource = FetchCloudServiceResource(cacheServiceName, out cloudServiceName); foreach (IntrinsicSettings.CacheServiceInput.NamedCache namedCache in cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches) { if (namedCache.CacheName.Equals(namedCacheName)) { throw new ArgumentException(string.Format(Properties.Resources.NamedCacheExists, cacheServiceName, namedCacheName)); } } if (cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType == CacheServiceSkuType.Basic) { throw new ArgumentException(Properties.Resources.NoAddInBasicSku); } else if (cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches.Count == MaxNamedCacheCount) { throw new ArgumentException(Properties.Resources.NoAddInAllSku); } IntrinsicSettings.CacheServiceInput.NamedCache newNamedCache = new IntrinsicSettings.CacheServiceInput.NamedCache(); newNamedCache.CacheName = namedCacheName; newNamedCache.EvictionPolicy = noeviction ? "None" : "LeastRecentlyUsed"; newNamedCache.ExpirationSettingsSection = new IntrinsicSettings.CacheServiceInput.NamedCache.ExpirationSettings(); newNamedCache.ExpirationSettingsSection.Type = expiryPolicy; newNamedCache.ExpirationSettingsSection.TimeToLiveInMinutes = expiryTimeInMinutes; newNamedCache.NotificationsEnabled = notifications; newNamedCache.HighAvailabilityEnabled = highAvailability; CacheServiceCreateParameters param = new CacheServiceCreateParameters(); param.IntrinsicSettingsSection = cacheResource.IntrinsicSettingsSection; param.ETag = cacheResource.ETag; param.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches.Add(newNamedCache); cacheResource = ProvisionCacheService(cloudServiceName, cacheResource.Name, param, false); return cacheResource; }
public CloudServiceResource SetNamedCache(string cacheServiceName, string namedCacheName, string expiryPolicy, int expiryTimeInMinutes, bool noeviction, bool notifications, bool highAvailability, Action <bool, string, string, string, Action> ConfirmAction, bool force) { string cloudServiceName = null; CloudServiceResource cacheResource = FetchCloudServiceResource(cacheServiceName, out cloudServiceName); bool namedCacheFound = false; IntrinsicSettings.CacheServiceInput.NamedCache updateNamedCache = null; foreach (IntrinsicSettings.CacheServiceInput.NamedCache namedCache in cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.NamedCaches) { if (namedCache.CacheName.Equals(namedCacheName)) { updateNamedCache = namedCache; namedCacheFound = true; break; } } if (!namedCacheFound) { throw new ArgumentException(string.Format(Properties.Resources.NamedCacheDoNotExists, cacheServiceName, namedCacheName)); } if (cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType == CacheServiceSkuType.Basic) { if (notifications) { throw new ArgumentException(Properties.Resources.NotificationsNotAvailable); } if (highAvailability) { throw new ArgumentException(Properties.Resources.HighAvailabilityNotAvailable); } } ConfirmAction( force, Properties.Resources.UpdateNamedCacheWarning, Properties.Resources.UpdatingNamedCache, cacheServiceName, () => { if (cacheResource.IntrinsicSettingsSection.CacheServiceInputSection.SkuType != CacheServiceSkuType.Basic) { updateNamedCache.NotificationsEnabled = notifications; updateNamedCache.HighAvailabilityEnabled = highAvailability; } updateNamedCache.EvictionPolicy = noeviction ? "None" : "LeastRecentlyUsed"; if (updateNamedCache.ExpirationSettingsSection == null) { updateNamedCache.ExpirationSettingsSection = new IntrinsicSettings.CacheServiceInput.NamedCache.ExpirationSettings(); } updateNamedCache.ExpirationSettingsSection.Type = expiryPolicy; updateNamedCache.ExpirationSettingsSection.TimeToLiveInMinutes = expiryTimeInMinutes; CacheServiceCreateParameters param = new CacheServiceCreateParameters(); param.IntrinsicSettingsSection = cacheResource.IntrinsicSettingsSection; param.ETag = cacheResource.ETag; cacheResource = ProvisionCacheService(cloudServiceName, cacheResource.Name, param, false); }); return(cacheResource); }