1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77"""Redis key generation utilities.
Provides consistent key generation functions for all Redis operations.
Ensures proper namespacing and key patterns across services.
"""
# Redis namespace prefix
REDIS_PREFIX = "eq-pdf"
# Secondary index: sorted set of job keys ordered by last-updated timestamp
JOBS_BY_UPDATED = f"{REDIS_PREFIX}:jobs-by-updated"
def job_key(job_id: str) -> str:
"""Generate Redis key for job status hash.
Args:
job_id: UUID format job identifier
Returns:
Redis key string: eq-pdf:job:{job_id}
Example:
>>> job_key("550e8400-e29b-41d4-a716-446655440000")
'eq-pdf:job:550e8400-e29b-41d4-a716-446655440000'
"""
return f"{REDIS_PREFIX}:job:{job_id}"
def queue_name(queue_type: str) -> str:
"""Generate Redis key for processing queue list.
Args:
queue_type: Type of queue (pii, approval, processing)
Returns:
Redis key string: eq-pdf:queue:{queue_type}
Example:
>>> queue_name("pii")
'eq-pdf:queue:pii'
"""
return f"{REDIS_PREFIX}:queue:{queue_type}"
def timeout_key(timeout_type: str) -> str:
"""Generate Redis key for timeout sorted set.
Args:
timeout_type: Type of timeout tracking (approval)
Returns:
Redis key string: eq-pdf:timeouts:{timeout_type}
Example:
>>> timeout_key("approval")
'eq-pdf:timeouts:approval'
"""
return f"{REDIS_PREFIX}:timeouts:{timeout_type}"
def metrics_key(metric_type: str) -> str:
"""Generate Redis key for metrics hash.
Args:
metric_type: Type of metrics (daily)
Returns:
Redis key string: eq-pdf:metrics:{metric_type}
Example:
>>> metrics_key("daily")
'eq-pdf:metrics:daily'
"""
return f"{REDIS_PREFIX}:metrics:{metric_type}"