Fix caching logic for non-200 responses in IP geolocation service

- Cache None for non-200 HTTP status codes to avoid repeated failed API calls
- Move exception handling cache to except block for consistency
parent c4a8a9b9
......@@ -28,12 +28,12 @@ async def get_ip_country(ip: str) -> Optional[str]:
country = response.text.strip().upper()
_ip_country_cache[ip] = country
return country
else:
_ip_country_cache[ip] = None
return None
except Exception:
pass
# Cache failure to avoid repeated calls
_ip_country_cache[ip] = None
return None
_ip_country_cache[ip] = None
return None
def is_ip_israeli(ip: str) -> bool:
"""Check if IP is from Israel."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment