-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcache_manager.py
More file actions
29 lines (24 loc) · 1.05 KB
/
cache_manager.py
File metadata and controls
29 lines (24 loc) · 1.05 KB
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
"""Cache management for processed emails"""
import json
import os
from config import EMAIL_CACHE_FILE
def load_email_cache():
"""Load previously processed email IDs from cache"""
if os.path.exists(EMAIL_CACHE_FILE):
try:
with open(EMAIL_CACHE_FILE, 'r', encoding='utf-8') as f:
cache = json.load(f)
print(f"Loaded cache with {len(cache.get('processed_ids', []))} previously processed emails")
return cache
except Exception as e:
print(f"Warning: Could not load cache file: {e}")
return {'processed_ids': [], 'applications': []}
return {'processed_ids': [], 'applications': []}
def save_email_cache(cache):
"""Save processed email IDs and applications to cache"""
try:
with open(EMAIL_CACHE_FILE, 'w', encoding='utf-8') as f:
json.dump(cache, f, indent=2, default=str)
print(f"Saved cache with {len(cache['processed_ids'])} processed emails")
except Exception as e:
print(f"Warning: Could not save cache file: {e}")