Reputation: 920
I am hosting a Net core application as as Azure app service. The app uses Microsoft.Extensions.Caching.Memory
to set and get string values to cache. Is there a way I can see the key-values stored in my server's in-memory cache ?
Reason:- The values I set, always seem to be null when I retrieve them. Is there anything like Redis console in azure portal to check the key values present in memory cache?
the part of code used to set and get.
_memoryCache.Set("key1", "value1", TimeSpan.FromHours(1))
_memoryCache.TryGetValue("key1", out string result)
Upvotes: 0
Views: 1418
Reputation: 21838
There is no function you mentioned on the azure portal.
Follow below steps, you can retrieve the value.
You need add services.AddMemoryCache();
in ConfigureServices.
And you also change your controller
like below. Then you will get the value. It will not be null.
Upvotes: 1