MemoryCache always returns “null” after first expiration
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have the following problem, I have this kind of cache management: public class CacheManager : ICacheManager { private readonly ObjectCache cache ; public CacheManager () { this . cache = MemoryCache . Default ; } public void AddItem ( string key , object itemToCache , double duration ) { var end = DateTime . Now . AddSeconds ( duration ); this . cache . Add ( key , itemToCache , end ); } public T Get < T >( string key ) where T : class { try { return ( T ) this . cache [ key ]; } catch ( Exception ex ) { return null ; } } public