Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道我是否可以在 MemoryCache 上实现一个方法,从其中删除一个项目并在任何其他线程尝试访问它之前添加一个新项目。我似乎找不到任何可以让我控制锁的东西(也许有充分的理由),所以我可以一次执行这两个操作。
If you mean "with the same key", then use the indexer:
cache[key] = value;
If you mean with different keys, then: no