import os
import hashlib
import json
def invalidate_cache(api_key, endpoint, cache_file="api_cache.json"):
"""
Invalidates the cache for a specific API endpoint.
For development use only.
"""
try:
with open(cache_file, 'r') as f:
cache = json.load(f)
except FileNotFoundError:
cache = {}
cache_key = f"{api_key}:{endpoint}"
if cache_key in cache:
del cache[cache_key]
print(f"Invalidated cache for {endpoint} using key {cache_key}")
else:
print(f"No cache found for {endpoint} using key {cache_key}")
with open(cache_file, 'w') as f:
json.dump(cache, f, indent=4)
if __name__ == '__main__':
# Example usage for development
api_key = "dev_api_key" # Replace with your development API key
endpoint = "/some/api/endpoint" # Replace with the specific endpoint.
invalidate_cache(api_key, endpoint)
Add your comment