mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
feat: Add black formatter to the project (#1544)
Add black formatter and run it on pytests
This commit is contained in:
parent
9448220607
commit
7944af3c62
21 changed files with 793 additions and 566 deletions
|
@ -12,40 +12,40 @@ def fill_set(args, redis: rclient.Redis):
|
|||
for j in range(args.num):
|
||||
token = uuid.uuid1().hex
|
||||
# print(token)
|
||||
key = f'USER_OTP:{token}'
|
||||
key = f"USER_OTP:{token}"
|
||||
arr = []
|
||||
for i in range(30):
|
||||
otp = ''.join(random.choices(
|
||||
string.ascii_uppercase + string.digits, k=12))
|
||||
otp = "".join(random.choices(string.ascii_uppercase + string.digits, k=12))
|
||||
arr.append(otp)
|
||||
redis.execute_command('sadd', key, *arr)
|
||||
|
||||
redis.execute_command("sadd", key, *arr)
|
||||
|
||||
|
||||
def fill_hset(args, redis):
|
||||
for j in range(args.num):
|
||||
token = uuid.uuid1().hex
|
||||
key = f'USER_INFO:{token}'
|
||||
phone = f'555-999-{j}'
|
||||
user_id = 'user' * 5 + f'-{j}'
|
||||
redis.hset(key, 'phone', phone)
|
||||
redis.hset(key, 'user_id', user_id)
|
||||
redis.hset(key, 'login_time', time.time())
|
||||
key = f"USER_INFO:{token}"
|
||||
phone = f"555-999-{j}"
|
||||
user_id = "user" * 5 + f"-{j}"
|
||||
redis.hset(key, "phone", phone)
|
||||
redis.hset(key, "user_id", user_id)
|
||||
redis.hset(key, "login_time", time.time())
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='fill hset entities')
|
||||
parser = argparse.ArgumentParser(description="fill hset entities")
|
||||
parser.add_argument("-p", type=int, help="redis port", dest="port", default=6380)
|
||||
parser.add_argument("-n", type=int, help="number of keys", dest="num", default=10000)
|
||||
parser.add_argument(
|
||||
'-p', type=int, help='redis port', dest='port', default=6380)
|
||||
parser.add_argument(
|
||||
'-n', type=int, help='number of keys', dest='num', default=10000)
|
||||
parser.add_argument(
|
||||
'--type', type=str, choices=['hset', 'set'], help='set type', default='hset')
|
||||
"--type", type=str, choices=["hset", "set"], help="set type", default="hset"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
redis = rclient.Redis(host='localhost', port=args.port, db=0)
|
||||
if args.type == 'hset':
|
||||
redis = rclient.Redis(host="localhost", port=args.port, db=0)
|
||||
if args.type == "hset":
|
||||
fill_hset(args, redis)
|
||||
elif args.type == 'set':
|
||||
elif args.type == "set":
|
||||
fill_set(args, redis)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue