I don't think this is a correct implementation -- it can miss keys if other keys earlier in the sort order are deleted between calls. Also, we should probably keep the documented behaviour of applying the filter after collecting a batch of keys to return.