import json


def _dump_db(duthost, db, key_pattern):
    """Dump redis database matching specificied key pattern"""
    command = "redis-dump -d {db} -k \"{key_pattern}\"".format(
        db=db, key_pattern=key_pattern)
    lines = duthost.shell(command)["stdout_lines"]
    return json.loads(lines[0])