def all(cls, list_name, offset=0, limit=-1): if limit != -1: limit -= 1 if offset != 0: offset -= 1 ids = redis_connection.zrevrange(list_name, offset, limit) pipe = redis_connection.pipeline() for id in ids: pipe.get(id) tasks = [cls.create_from_data(data) for data in pipe.execute()] return tasks