'Returns subset of entities that have had new things since the
given position. If the position is too old it will just return the given list.'

def get_entities_changed(self, entities, stream_pos):

    assert (type(stream_pos) is int)
    if (stream_pos >= self._earliest_known_stream_pos):
        keys = self._cache.keys()
        i = keys.bisect_right(stream_pos)
        result = set((self._cache[k] for k in keys[i:])).intersection(entities)
        self.metrics.inc_hits()
    else:
        result = entities
        self.metrics.inc_misses()
    return result
