public void StartCacheProcesses() { factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration()); shortCacheManager = factory.Create("ShortInMemoryPersistence"); smallCacheManager = factory.Create("SmallInMemoryPersistence"); expiredKeys = ""; expiredValues = ""; removalReasons = ""; }
public void GetCacheManagerWithNullEncryption() { CacheManagerFactory factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration()); ICacheManager mgr = factory.Create("InMemoryPersistenceWithNullEncryption"); CacheManagerTest(mgr); }
public void WillThrowExceptionIfCannotFindSection() { CacheManagerFactory factory2 = new CacheManagerFactory(new DictionaryConfigurationSource()); factory2.Create("some name"); Assert.Fail("Should have thrown ConfigurationErrorsException"); }
public void TestInitialize() { CacheManagerFactory factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration()); cache = factory.Create("InDatabasePersistence"); cache.Flush(); wasCalledBack = false; initializationCount = 0; }
public void CreateCache() { removedKey = null; expiredValue = null; removalReason = CacheItemRemovedReason.Unknown; factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration()); cacheMgr = (CacheManager)factory.Create("SmallInMemoryPersistence"); }
public void ThenReturnsNewlyConfiguredInstanceAfterReconfigureOfCacheManager() { cacheManagerData.Name = "New Name"; configurationSource.DoSourceChanged(new string[]{CacheManagerSettings.SectionName}); CacheManagerFactory factory = new CacheManagerFactory(serviceLcoator); ICacheManager cacheManager = factory.Create("New Name"); Assert.IsNotNull(cacheManager); }
public void CallingDifferentFactoryTwiceReturnsDifferentInstances() { CacheManager cacheOne = factory.Create("InMemoryPersistence"); CacheManagerFactory secondFactory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration()); CacheManager cacheTwo = secondFactory.Create("InMemoryPersistence"); Assert.IsFalse(object.ReferenceEquals(cacheOne, cacheTwo), "Different factories should always return different instances for same instance name"); }
public void ThenReturnsNewlyConfiguredInstanceAfterReconfigureOfCacheManager() { cacheManagerData.Name = "New Name"; configurationSource.DoSourceChanged(new string[] { CacheManagerSettings.SectionName }); CacheManagerFactory factory = new CacheManagerFactory(serviceLcoator); ICacheManager cacheManager = factory.Create("New Name"); Assert.IsNotNull(cacheManager); }
void CacheManagerTest(string instanceName) { CacheManagerFactory factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration()); ICacheManager mgr = factory.Create(instanceName); string key = "key1"; string val = "value123"; mgr.Add(key, val); string result = (string)mgr.GetData(key); Assert.AreEqual(val, result, "result"); }
public void CanCreateIsolatedStorageCacheManager() { cacheManager.Add("bab", "foo"); Assert.AreEqual(1, cacheManager.Count); CacheManagerFactory differentFactory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration()); CacheManager differentCacheManager = differentFactory.Create("InIsoStorePersistence"); int count = differentCacheManager.Count; differentCacheManager.Dispose(); Assert.AreEqual(1, count, "If we actually persisted added item, different cache manager should see item, too."); }
private void CacheManagerTest(string instanceName) { CacheManagerFactory factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration()); CacheManager mgr = factory.Create(instanceName); string key = "key1"; string val = "value123"; mgr.Add(key, val); string result = (string)mgr.GetData(key); Assert.AreEqual(val, result, "result"); }
private ICacheManager GetCacheManager() { ICacheManager cacheManager; lock (cacheLock) { if (!cacheManagers.ContainsKey(Group)) { CacheManagerFactory cacheManagerFactory = new CacheManagerFactory(GetConfigurationSource()); cacheManagers.Add(Group, cacheManagerFactory.Create(Group)); } cacheManager = cacheManagers[Group]; } return(cacheManager); }
public void ThenReturnsNewlyConfiguredInstanceAfterReconfigureOfBackingStore() { MockCustomStorageBackingStore.Instantiated = false; cacheSettings.BackingStores.Remove("Null Storage"); cacheSettings.BackingStores.Add(new CustomCacheStorageData("Custom Store", typeof(MockCustomStorageBackingStore))); cacheManagerData.CacheStorage = "Custom Store"; configurationSource.DoSourceChanged(new string[] { CacheManagerSettings.SectionName }); CacheManagerFactory factory = new CacheManagerFactory(serviceLcoator); ICacheManager cacheManager = factory.Create(cacheSettings.DefaultCacheManager); Assert.IsTrue(MockCustomStorageBackingStore.Instantiated); }
public static ICacheManager Create(string configSource, string cacheName) { ICacheManager cache; FileConfigurationSource config = new FileConfigurationSource(configSource); CacheManagerFactory cf = new CacheManagerFactory(config); if (string.IsNullOrEmpty(cacheName)) { cache = cf.Create(cacheName); } else { cache = cf.CreateDefault(); } return(cache); }
public CacheManager GetCacheManagerByGroupName(string groupName) { lock (caches) { if (caches.ContainsKey(groupName)) { return(caches[groupName]); } CacheManagerFactory cacheManagerFactory = new CacheManagerFactory(GetCacheConfiguration(groupName)); CacheManager cacheManager = cacheManagerFactory.Create(groupName); if (cacheManager != null) { caches.Add(groupName, cacheManager); } return(cacheManager); } }
public IDeliveryClient Get(string name) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (!_cache.TryGetValue(name, out var client)) { client = _innerDeliveryClientFactory.Get(name); if (client != null) { var cacheOptions = _deliveryCacheOptions.Get(name); if (cacheOptions.Name == name) { // Build caching services according to the options IDeliveryCacheManager manager; if (cacheOptions.CacheType == CacheTypeEnum.Memory) { var memoryCache = GetNamedServiceOrDefault <IMemoryCache>(name); manager = CacheManagerFactory.Create(memoryCache, Options.Create(cacheOptions)); } else { var distributedCache = GetNamedServiceOrDefault <IDistributedCache>(name); manager = CacheManagerFactory.Create(distributedCache, Options.Create(cacheOptions)); } // Decorate the client with a caching layer client = new DeliveryClientCache(manager, client); _cache.TryAdd(name, client); } } } return(client); }
public void ThenReturnsNewlyConfiguredInstanceAfterReconfigureOfStorageEncryptionProvider() { MockStorageEncryptionProvider.Instantiated = false; storageEncryptionProviderData = new MockStorageEncryptionProviderData("Storage Encryption"); cacheSettings.EncryptionProviders.Add(storageEncryptionProviderData); IsolatedStorageCacheStorageData isolatedStoreData = new IsolatedStorageCacheStorageData(); isolatedStoreData.Name = "Isolated Storage"; isolatedStoreData.PartitionName = "entlib"; isolatedStoreData.StorageEncryption = storageEncryptionProviderData.Name; cacheSettings.BackingStores.Add(isolatedStoreData); cacheManagerData.CacheStorage = isolatedStoreData.Name; configurationSource.DoSourceChanged(new string[] { CacheManagerSettings.SectionName }); CacheManagerFactory factory = new CacheManagerFactory(serviceLcoator); ICacheManager cacheManager = factory.Create(cacheSettings.DefaultCacheManager); Assert.IsTrue(MockStorageEncryptionProvider.Instantiated); }
public void TestInitialize() { CacheManagerFactory factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration()); cache = factory.Create("InDatabasePersistence"); }
public void Create_MemoryCache() { var deliveryCacheManager = CacheManagerFactory.Create(_memoryCache, _options); deliveryCacheManager.Should().NotBeNull(); }
public void CreateCacheManager() { factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration()); cacheManager = factory.Create("InIsoStorePersistence"); cacheManager.Flush(); }
public void TestInitialize() { CacheManagerFactory factory = new CacheManagerFactory(TestConfigurationSource.GenerateConfiguration()); cache = (CacheManager)factory.Create("InDatabasePersistence"); }
public void CreateNamedCacheInstance() { CacheManager cache = factory.Create("InMemoryPersistence"); Assert.IsNotNull(cache, "Should have created caching instance through factory"); }
public void Create_DistributedCache() { var deliveryCacheManager = CacheManagerFactory.Create(_distributedCache, _options); deliveryCacheManager.Should().NotBeNull(); }