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.

2
  • What do you mean by "first"? Why would you even care? What makes you even think the cache keeps things in order of insertion? Commented Oct 19, 2022 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? Commented Oct 20, 2022 at 11:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.