在生产或QA测试中的webapi2的内存缓存测试中

时间:2018-01-21 18:14:12

标签: asp.net-web-api asp.net-web-api2 memorycache asp.net-caching

如何在生产或QA环境中测试内存缓存逻辑。

//If the data exists in cache, pull it from there, otherwise make a call to database to get the data
ObjectCache cache = MemoryCache.Default;

var peopleData = cache.Get("PeopleData") as List<People>;
if (peopleData != null)
   return peopleData ;

peopleData = GetAllPeople();
CacheItemPolicy policy = new CacheItemPolicy {AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(30)};
cache.Add("PeopleData", peopleData, policy);
return peopleData;

如何在不同环境中部署后测试功能。

0 个答案:

没有答案