Can I add atomic operation to MemoryCache?

I would like to know if I can implement a method on MemoryCache that removes an item from it and adds a new one before any other thread tries to grab it. I cannot find anything that would allow me to manage the lock (perhaps for a good reason), so I can perform these two operations at once.


source to share

1 answer

If you mean "with the same key" use an index:

cache[key] = value;


If you mean different keys, then: no



All Articles