How can I detach the object reference on MemoryCache

前端 未结 5 550
轮回少年
轮回少年 2021-01-04 03:26

I\'m currently trying out the new MemoryCache in .Net 4 to cache a few bits of data in one of our apps. The trouble I have is the objects are updated and the ca

5条回答
  •  醉梦人生
    2021-01-04 04:12

    Serialization/Deserialization will solve the problem but at the same time it defeats the porpose of having objects in memory. The role of cache is to provide fast access to the stored object and we are adding the deserialization overhead here. Since deserialization is required I would suggest cache as service , something like redis cache, it will be centralized so you don't have to have copy of memory object per worker process and deserialization is anyways done.

    The key thing in this case that you chose a fast serialization/deserialization option.

提交回复
热议问题