jmdns: JmDNS should provide an API to invalidate the cache
I have a situation where I need to check for services currently available in the network. These services may come and go so I need to recheck, either periodically or when triggered by the user.
However I have found that after JmDNS has discovered a service, it will keep returning cached information regardless of whether the device is still present in the network. I have tried unregistering the listener and registering it again, but when I do this serviceAdded
is immediately called with stale (cached) information.
Is there any way to force JmDNS to drop any cached information so that I can start a “fresh” search, other than calling JmDNS.close()
? (this works, but it takes a few seconds to complete).
About this issue
- Original URL
- State: open
- Created 9 years ago
- Reactions: 1
- Comments: 18 (4 by maintainers)
@ViToni This issue was actually about the need to have a way to trigger a “re-check”, discarding any cached information. This was even more necessary due to #18, which is now fixed with your changes (#126), but there are other cases, see comment from @namannik:
(this was #18, now fixed)
Due to the above I need a way to force a re-check discarding any items that may still be cached. Currently the only ways I have found to do that are:
((JmDNSImpl) jmdns).getCache().clear()
, which is not a public API, but works fine.