C#: How to implement a smart cache

后端 未结 6 520
离开以前
离开以前 2021-01-31 05:26

I have some places where implementing some sort of cache might be useful. For example in cases of doing resource lookups based on custom strings, finding names of properties usi

6条回答
  •  借酒劲吻你
    2021-01-31 05:41

    This is a nice debate to have, but depending your application, here's some tips:

    You should define the max size of the cache, what to do with old items if your cache is full, have a scavenging strategy, determine a time to live of the object in the cache, does your cache can/must be persisted somewhere else that memory, in case of application abnormal termination, ...

提交回复
热议问题