The current handling in the caching routine for getent style calls does not sufficiently maintain state.
At the end of the mp-read when it detects end of stream it resets its state to the initial state; this has the effect that subsequent calls to 'getent' will just automatically rewind to the head of the state, in the case of the cache daemon this means that you will iterate through the entire cache, then get a single record of the next datasource, and then loop through the entire cache AGAIN, get the next datatsource, etc.
The fix here is to NOT reset to the initial state at detected end of stream but record the fact that you are at the end of the stream. The existing 'setent' routines which are designed to rewind the stream then correctly reset the state.