my ideal cache using guava

前端 未结 2 1221
星月不相逢
星月不相逢 2020-12-13 07:03

Off and on for the past few weeks I\'ve been trying to find my ideal cache implementation using guava\'s MapMaker. See my previous two questions here and here to follow my t

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 07:40

    I don't understand the full picture here, but two things.

    1. Given this statement: "this implementation will evict objects even if they are strongly reachable, once their time is up. This could result in multiple objects with the same UID floating around in the environment, which I don't want." -- it sounds like you just need to use weakKeys() and NOT use either timed or size-based eviction.

    2. Or if you do want to bring an "interner" into this, I'd use a real Interners.newWeakInterner.

提交回复
热议问题