Skip to content

Open id metadata cache refresh if key is missing #1487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,16 @@ def __init__(self, url):
self.last_updated = datetime.min

async def get(self, key_id: str):
# If keys are more than 5 days old, refresh them
if self.last_updated < (datetime.now() - timedelta(days=5)):
# If keys are more than 1 day old, refresh them
if self.last_updated < (datetime.now() - timedelta(days=1)):
await self._refresh()
return self._find(key_id)

key = self._find(key_id)
if not key and self.last_updated < (datetime.now() - timedelta(hours=1)):
# Refresh the cache if a key is not found (max once per hour)
await self._refresh()
key = self._find(key_id)
return key

async def _refresh(self):
response = requests.get(self.url)
Expand Down