import redis


def log_to_redis(host="localhost", port=6379, dbn=11):
    """Record the tuning record to a redis DB.

    Parameters
    ----------
    host: str, optional
        Host address of redis db
    port: int, optional
        Port of redis db
    dbn: int, optional
        which redis db to use, default 11
    """
    # import here so only depend on redis when necessary
    red = redis.StrictRedis(host=host, port=port, db=dbn)

    def _callback(_, inputs, results):
        """Callback implementation"""
        for inp, result in zip(inputs, results):
            red.set(inp, result)
    return _callback