//[ValidateRequestModel] public async Task <string> GetTest1Response() { //var value = distributedCache.Get("name-key"); //string valStr = string.Empty; //if (value == null) //{ // valStr = "孙悟空三打白骨精!"; // // 存储的数据必须为字节,所以需要转换一下 // var encoded = Encoding.UTF8.GetBytes(valStr); // // 配置类:30秒过时 // var options = new DistributedCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(30)); // distributedCache.Set("name-key", encoded, options); // distributedCache.SetString("test", "111111"); //} var value = RedisHelper.Get("name-key"); string valStr = string.Empty; if (value == null) { valStr = "孙悟空三打白骨精!"; RedisHelper.Set("name-key", valStr, 30); } await testServices.GetUserCountAsync(); return(HttpContextGlobal.CurrentTraceId.ToString()); }