rate_limiter: Extract KEY_PREFIX to redis_utils.

(cherry picked from commit 630335142a)
This commit is contained in:
Mateusz Mandera
2024-03-19 02:46:33 +01:00
committed by Tim Abbott
parent 0afcfccd20
commit 2deb166a23
3 changed files with 13 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
import os
import re
import secrets
from typing import Any, Dict, Mapping, Optional
@@ -84,3 +85,11 @@ def validate_key_fits_format(key: str, key_format: str) -> None:
if not re.fullmatch(regex, key):
raise ZulipRedisKeyOfWrongFormatError(f"{key} does not match format {key_format}")
REDIS_KEY_PREFIX = ""
def bounce_redis_key_prefix_for_testing(test_name: str) -> None:
global REDIS_KEY_PREFIX
REDIS_KEY_PREFIX = test_name + ":" + str(os.getpid()) + ":"