Skip to content
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

feat(server/core): generalize caching mechanism, and update getServerInfoFactory to rely on getServerConfig dependency #3791

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

iainsproat
Copy link
Contributor

@iainsproat iainsproat commented Jan 9, 2025

Description & motivation

Following the pattern set by knex, we instantiate a client (in this case the cache directly) in a central location which can be accessed by all callers.

Separates the caching retrieval and setting to a general, and generic, handler.

We provide a handler around the knex query to get the server config, allowing it to be used in the caching handler.

We update all references of getServerInfo to use the new signature. For now, we have these directly call the db without caching (except in the resolver which is already cached).

Changes:

  • health check of postgres now retrieves server config, not server info. health check should never be cached (bustCache is always set to true, even though it uses a method without caching).
  • cache value in memory with short TTL (configurable); this is created in the module to be used by all calls to server info where required.
  • server config is a dependency of server info, and has to be passed in by all callers
  • for now, the majority of calls do not go via the cache. Instead using getServerConfigFactory to call the database directly

To-do before merge:

Screenshots:

Validation of changes:

Checklist:

  • My pull request follows the guidelines in the Contributing guide?
  • My pull request does not duplicate any other open Pull Requests for the same update/change?
  • My commits are related to the pull request and do not amend unrelated code or documentation.
  • My code follows a similar style to existing code.
  • I have added appropriate tests.
  • I have updated or added relevant documentation.

References

- cache returned value in Redis
- allow config to be queried separately
Copy link

linear bot commented Jan 9, 2025

@iainsproat iainsproat changed the title feat(server/core): optimise serverInfo database query WIP: feat(server/core): optimise serverInfo database query Jan 9, 2025
@gjedlicska
Copy link
Contributor

closing in favor of a leaner approach in #3808

@gjedlicska gjedlicska closed this Jan 13, 2025
@iainsproat iainsproat reopened this Jan 14, 2025
@iainsproat iainsproat changed the title WIP: feat(server/core): optimise serverInfo database query feat(server/core): optimise serverInfo database query Jan 14, 2025
@iainsproat iainsproat changed the title feat(server/core): optimise serverInfo database query feat(server/core): generalize caching mechanism, and update serverInfo to rely on getServerConfig dependency Jan 14, 2025
@iainsproat iainsproat changed the title feat(server/core): generalize caching mechanism, and update serverInfo to rely on getServerConfig dependency feat(server/core): generalize caching mechanism, and update serverInfo to rely on getServerConfig` dependency Jan 15, 2025
@iainsproat iainsproat changed the title feat(server/core): generalize caching mechanism, and update serverInfo to rely on getServerConfig` dependency feat(server/core): generalize caching mechanism, and update getServerInfoFactory to rely on getServerConfig dependency Jan 15, 2025
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