user1016765 user1016765 -4 years ago 176
Java Question

Guava cache listener for insertions

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
?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download