public void Does_cache_by_custom_CacheKey() { ServerCustomCacheKey.Count = 0; var request = new ServerCustomCacheKey { Id = 8, Value = "foo" }; var response = Config.ListeningOn.CombineWith(request.ToGetUrl()) .GetJsonFromUrl() .FromJson <ServerCustomCacheKey>(); Assert.That(ServerCustomCacheKey.Count, Is.EqualTo(1)); AssertEquals(response, request); response = Config.ListeningOn.CombineWith(request.ToGetUrl()) .GetJsonFromUrl() .FromJson <ServerCustomCacheKey>(); Assert.That(ServerCustomCacheKey.Count, Is.EqualTo(2)); AssertEquals(response, request); response = Config.ListeningOn.CombineWith(request.ToGetUrl()) .GetJsonFromUrl() .FromJson <ServerCustomCacheKey>(); Assert.That(ServerCustomCacheKey.Count, Is.EqualTo(2)); AssertEquals(response, request); }
public async Task <object> Any(ServerCustomCacheKey request) { if (Request.GetItem(Keywords.CacheInfo) is CacheInfo cacheInfo) { cacheInfo.KeyBase += "::flag=" + (ServerCustomCacheKey.Count % 2 == 0); if (await Request.HandleValidCache(cacheInfo)) { return(null); } } Interlocked.Increment(ref ServerCustomCacheKey.Count); return(request); }
public object Any(ServerCustomCacheKey request) { var cacheInfo = Request.GetItem(Keywords.CacheInfo) as CacheInfo; if (cacheInfo != null) { cacheInfo.KeyBase += "::flag=" + (ServerCustomCacheKey.Count % 2 == 0); if (Request.HandleValidCache(cacheInfo)) { return(null); } } Interlocked.Increment(ref ServerCustomCacheKey.Count); return(request); }