public GetConfigurationDocumentResponse GetConfigurationDocument(GetConfigurationDocumentRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.DocumentKey, "DocumentKey"); return(GetConfigurationDocumentHelper(request.DocumentKey)); }
public void TestCacheConfigurationDocument() { var cache = new TestCacheClient(); cache.ClearCache(); var documentKey = new ConfigurationDocumentKey("Test", new Version(1, 0), null, ""); var cacheKey = ((IDefinesCacheKey)documentKey).GetCacheKey(); var service = new TestConfigurationService(); object request = new GetConfigurationDocumentRequest(documentKey); object response = new GetConfigurationDocumentResponse(documentKey, DateTime.Now, DateTime.Now, "Test"); var invocation = new TestInvocation { Target = service, Method = typeof(IApplicationConfigurationReadService).GetMethod("GetConfigurationDocument", BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public), TargetType = typeof(IApplicationConfigurationReadService), Request = request, Response = response }; var directive = new ResponseCachingDirective(true, TimeSpan.FromMinutes(1), ResponseCachingSite.Server); var advice = new ConcreteResponseCachingAdvice(directive); advice.Intercept(invocation); var cacheEntry = cache.Get(cacheKey, new CacheGetOptions("")); Assert.IsNotNull(cacheEntry); Assert.AreEqual(response, cacheEntry); request = new SetConfigurationDocumentRequest(documentKey, "Test"); response = new SetConfigurationDocumentResponse(); invocation = new TestInvocation { Target = service, Method = typeof(IConfigurationService).GetMethod("SetConfigurationDocument", BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public), TargetType = typeof(IConfigurationService), Request = request, Response = response }; advice = new ConcreteResponseCachingAdvice(null); advice.Intercept(invocation); cacheEntry = cache.Get(cacheKey, new CacheGetOptions("")); Assert.IsNull(cacheEntry); }
/// <summary> /// This method is called automatically by response caching framework /// to provide caching directive for configuration documents. /// </summary> /// <param name="request"></param> /// <returns></returns> protected ResponseCachingDirective GetDocumentCachingDirective(GetConfigurationDocumentRequest request) { // if the request is for ConfigurationStoreSettings, we cannot try to load // these settings to read the values, or we'll get into an infinite recursion // therefore, we assume ConfigurationStoreSettings are simply never cached. // a better solution would be to allow each settings group to specify its own // cacheability, and store this in the db with the settings meta-data // but this is not currently implemented if (request.DocumentKey.DocumentName == typeof(ConfigurationStoreSettings).FullName) { return(ResponseCachingDirective.DoNotCacheDirective); } var settings = new ConfigurationStoreSettings(); return(new ResponseCachingDirective( settings.ConfigurationCachingEnabled, TimeSpan.FromSeconds(settings.ConfigurationCachingTimeToLiveSeconds), ResponseCachingSite.Client)); }
public GetConfigurationDocumentResponse GetConfigurationDocument(GetConfigurationDocumentRequest request) { throw new NotImplementedException(); }