'Trim the sorted set to max length
zremrangebyscore'

def trim(self, max_length=None):

    key = self.get_key()
    if (max_length is None):
        max_length = self.max_length
    if self.sort_asc:
        begin = max_length
        end = (-1)
    else:
        begin = 0
        end = ((max_length * (-1)) - 1)
    removed = self.redis.zremrangebyrank(key, begin, end)
    logger.info(('cleaning    up    the    sorted    set    %s    to    a    max    of    %s    items' % (key, max_length)))
    return removed
