I am using LazyCache.AspNetCore
package from nuget to store some data in memory and read from memory. this is my sample code:
IAppCache cache = new CachingService();
StopWatch _watch;
public async Task TestAsync(UserInfo user){
var key = await CreateCustomTokenAsync(user.X);
_watch = new Stopwatch();
_watch.Start();
var val = await cache.GetAsync<string>(key);
if (val== user.Y) {
var timeTaken = _watch.Elapsed.TotalMilliseconds;
log(timeTaken);
_watch.Stop();
return;
}
// ...
}
but the response time
gets high more than 20 ms. I am wondering how I can fix
this problem because reading from memory is supposed to be less than 20 ms.