Skip to content

Comments

Cache static routes#457

Draft
chaen wants to merge 1 commit intoDIRACGrid:mainfrom
chaen:general_speedup
Draft

Cache static routes#457
chaen wants to merge 1 commit intoDIRACGrid:mainfrom
chaen:general_speedup

Conversation

@chaen
Copy link
Contributor

@chaen chaen commented Apr 8, 2025

No description provided.

Copy link
Contributor

@aldbr aldbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks interesting. Any reason for not finishing it?

router = DiracxRouter(require_auth=False, path_root="")


_static_cache: TTLCache = TTLCache(maxsize=5, ttl=60)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why maxsize=5?
IIUC, we would need at least maxsize=2 here, 4 looks generous enough (to keep the old and new entries for a brief moment?), right?

And the ttl could be a bit longer I guess.

Suggested change
_static_cache: TTLCache = TTLCache(maxsize=5, ttl=60)
_static_cache: TTLCache = TTLCache(maxsize=4, ttl=300)

"""Get metadata about the dirac installation."""
return await get_installation_metadata_bl(config)
cached_hash = f"dirac-metadata:{config._hexsha}"
if cached_hash not in _static_cache:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I think extensions like gubbins could also benefit from the cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants