Automatically re-populate the cache at expiry time

前端 未结 4 1164
悲哀的现实
悲哀的现实 2021-02-09 14:52

I currently cache the result of a method invocation.

The caching code follows the standard pattern: it uses the item in the cache if it exists, otherwise it calculates t

4条回答
  •  孤城傲影
    2021-02-09 15:22

    A new addition to the .NET Framework 4.0 is the MemoryCache Class

    Quote from the Docs:

    The MemoryCache class is similar to the ASP.NET Cache class. The MemoryCache class has many properties and methods for accessing the cache that will be familiar to you if you have used the ASP.NET Cache class

    You could use the AddOrGetExisting Method to get or create a CacheItem if does not exist.

提交回复
热议问题