0

I'm working on some solution where I need first value of the in-memory cache and I don't know the key of the first value.

How can I get the key of item at beginning of the in-memory cache?

I'm using this:

IMemoryCache _memoryCache; 

from the Microsoft.Extensions.Caching.Memory namespace.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • What do you mean by "first"? Why would you even care? What makes you even think the cache keeps things in order of insertion? – DavidG Oct 19 '22 at 12:32
  • @DavidG I want to implement LRU in my caching where I want to remove the first inserted item if cache reaches the max capacity. I can use another DS like Queue to store the keys while inserting in cache and delete the first item from cache using the first key from queue. Here the problem is my cache data expires after 1 minute so there might be situation that key is present in queue but is deleted from cache. One thing is why cache does not store the data in order? – Mayank Tripathi Oct 20 '22 at 11:32

0 Answers0