I don't use ltrim because this function removes elements from the left, and the newest failures are added from the right. It may be possible to do some thing with negative value in params but ltrim is a O(N) operation and lpop a O(1).