In Memory Cache testing for webapi2 in Production Or QA Testing

116 Views Asked by At

How to test the In Memory caching logic in production or QA environment.

//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;

How to test the functionalities after deployment in Different Environmens.

1

There are 1 best solutions below

0
Caffeine Coder On

@MohamedSahir there are 2 ways-

  1. In QA environment , you must be having some logging mechanism like Kibana or plain log files generation over your host server. Then with the help of appropriate log message, you can see whether it is either a cache hit or miss.

  2. Use performance counter as mentioned here