dylanebert commited on
Commit
f4eb0a2
·
1 Parent(s): a544d54

timestamp bugfix

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -161,9 +161,14 @@ def cached_request(url: str, timeout: int = REQUEST_TIMEOUT) -> Optional[request
161
  # Check cache
162
  if url in _scrape_cache:
163
  cache_entry = _scrape_cache[url]
164
- if time.time() - cache_entry["timestamp"] < CACHE_TTL:
165
- logger.debug(f"Cache hit for {url}")
166
- return cache_entry["data"]
 
 
 
 
 
167
 
168
  # Make request with retries
169
  for attempt in range(MAX_RETRIES):
 
161
  # Check cache
162
  if url in _scrape_cache:
163
  cache_entry = _scrape_cache[url]
164
+ # Handle both old and new cache formats
165
+ if isinstance(cache_entry, dict) and "timestamp" in cache_entry:
166
+ if time.time() - cache_entry["timestamp"] < CACHE_TTL:
167
+ logger.debug(f"Cache hit for {url}")
168
+ return cache_entry["data"]
169
+ else:
170
+ # Old cache format, clear it
171
+ del _scrape_cache[url]
172
 
173
  # Make request with retries
174
  for attempt in range(MAX_RETRIES):