'Sometimes EnyimMemcachedCore/IMemoryCache getting null

I have tried both EnyimMemcachedCore and IMemoryCache but values are getting null sometimes. and getting below error in both.

Exception: System.ArgumentNullException: Value cannot be null. (Parameter 's') at

Below is my code(I tried both EnyimMemcachedCore and IMemoryCache)

private readonly IMemoryCache _memoryCache;
public static CacheService _cacheMemory = new();

_cacheMemory.AddCacheData("flightData_" + _uid, FlightMainData, 1800);
_memoryCache.Set("flightData_1" + _uid, FlightMainData.Medium, DateTimeOffset.UtcNow.AddMinutes(30));

I am retrieving like below,

var resultsData = _cacheMemory.GetCacheData("flightData_" + _uid);
var resultsData1 = _memoryCache.Get<string>("flightData_1" + _uid);

FYI: I am storing a little big-size data to cache and also the traffic of my site is very high. Is this because of the heavy traffic I am getting or anything else? Please help me with this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source