Guava cache listener for insertions

拟墨画扇 提交于 2020-01-24 15:37:05

问题


We'd find it very useful to have an AddListener to complement RemovalListener in Google Guava.

Is there a suitable alternative to an AddListener that would complement RemovalListener?


回答1:


You can provide that yourself - just pass your custom listener to your computing Function, and whenever you compute a value, notify the listener.

If you are using asMap().put(..), then you'd have to wrap the whole thing in in your custom classes that delegate to the originals but also invoke the addition listener.



来源:https://stackoverflow.com/questions/7978169/guava-cache-listener-for-insertions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!