HashMap with weak values

前端 未结 7 2342
悲&欢浪女
悲&欢浪女 2021-02-18 14:03

I\'m implementing a cache for Objects stored persistently. The idea is:

  • Method getObjectFromPersistence(long id); ///Takes about 3 seconds
  • M
7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-18 14:22

    You could start a "cleanup" - Thread every once in a while. Perhaps if your map size exceeds a threshold but at most every 5 minutes .... something like that.

    Keep the cleanup cycles short to not block the main functionality.

提交回复
热议问题