static Nested() { try { var cacheConfig = App.Config.Sys.Cache; if (null == Config) { Config = new MdCacheConfig(cacheConfig.Identifier, cacheConfig.CacheName, cacheConfig.AuthorizationToken); } if (MasterConfig.ConfigStorageConnectionString != null) { Trace.TraceInformation("[MdCache] Attaching to BlobCache {0}", MasterConfig.ConfigStorageConnectionString); _instance = new AzureBlobCache(MasterConfig.ConfigStorageConnectionString); } else if (!string.IsNullOrWhiteSpace(cacheConfig.LocalCacheDir)) { Trace.TraceInformation("[MdCache] Attaching to LocalCache"); _instance = new LocalMdCache(); } else if (Config.CacheName != null) { _instance = new AzureMdCache(Config); } else { _instance = new NullCache(); } } catch (Exception e) { Trace.TraceError("[MdCache] Nested.Nested() failed. {0}", e); throw; } }
public void AzureCacheTest() { string key = "Key1" + Guid.NewGuid().ToString("D"); const string value = "Value1"; IMdCache cache = new AzureMdCache( new MdCacheConfig( "enterprisemedia.cache.windows.net", "default", "YWNzOmh0dHBzOi8vZW50ZXJwcmlzZW1lZGlhODE3Ni1jYWNoZS5hY2Nlc3Njb250cm9sLndpbmRvd3MubmV0Ly9XUkFQdjAuOS8mb3duZXImek1BNXBSR1ZhdXpaZ3ZLM2NGanMrR2N2RGRkWlBVb1pGVDRpNk9HbmlaRT0maHR0cDovL2VudGVycHJpc2VtZWRpYS5jYWNoZS53aW5kb3dzLm5ldC8=" ) ); cache.Set(key, value, TimeSpan.FromMinutes(1)); string readvalue = cache.Get(key); Assert.AreEqual(value, readvalue); }