import time
from redis import Redis


def redis_scan(host, port, password, db, match, count, interval, show_type):
    client = Redis(host=host, port=port, password=password, db=db)
    cursor, num = 0, 0

    while True:
        cursor, keys = client.scan(cursor, match=match, count=count)
        num += len(keys)
        for key in keys:
            print(key.decode("utf-8"))
            if show_type:
                print(client.type(key).decode('utf-8'))

        if cursor == 0:
            break
        time.sleep(float(interval))
        print(float(interval))
    print("Total Key Number:%s" % num)

import time
from redis import Redis


def redis_scan(host, port, password, db, match, count, interval, show_type):
    client = Redis(host=host, port=port, password=password, db=db)
    cursor, num = 0, 0

    while True:
        cursor, keys = client.scan(cursor, match=match, count=count)
        num += len(keys)
        for key in keys:
            print(key.decode("utf-8"))
            if show_type:
                print(client.type(key).decode('utf-8'))

        if cursor == 0:
            break
        time.sleep(float(interval))
        print(float(interval))
    print("Total Key Number:%s" % num)
