Skip to content

feat(cache): Add Memory Caching In Format Versions Endpoint #559

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 1 commit into from
Apr 28, 2025

Conversation

hf-krechan
Copy link
Collaborator

No description provided.

@hf-krechan hf-krechan requested a review from hf-aschloegl April 28, 2025 12:43
@hf-krechan hf-krechan changed the title add memory caching in format versions endpoint feat(cache): Add Memory Caching In Format Versions Endpoint Apr 28, 2025
@hf-kklein hf-kklein requested a review from Copilot April 28, 2025 13:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds memory caching to the endpoint that returns format versions, improving performance by reducing repetitive database lookups. Key changes include:

  • Introducing an in-memory cache with an expiration mechanism in the repository.
  • Incorporating HTTP caching headers, including Cache-Control and ETag, in the controller response.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/server/repository/formatVersion.ts Added memory caching for format versions with a TTL check
src/server/controller/formatVersion.ts Added HTTP cache headers and an ETag based on the list content

Comment on lines +16 to +17
.setHeader('ETag', `"${formatVersionEntity.join(',')}"`) // Simple ETag based on content
.send(formatVersionEntity);
Copy link
Preview

Copilot AI Apr 28, 2025

Choose a reason for hiding this comment

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

The current ETag generation concatenates version strings using commas, which may lead to collisions if any version string contains a comma. Consider using a hash function to create a more robust and unique ETag.

Suggested change
.setHeader('ETag', `"${formatVersionEntity.join(',')}"`) // Simple ETag based on content
.send(formatVersionEntity);
.setHeader('ETag', `"${this.generateETag(formatVersionEntity)}"`) // Robust ETag using hash function

Copilot uses AI. Check for mistakes.

@hf-krechan hf-krechan merged commit b56ec4b into main Apr 28, 2025
3 of 4 checks passed
@hf-krechan hf-krechan deleted the improve-format-version-request branch April 28, 2025 13:53
hf-kklein pushed a commit that referenced this pull request Apr 29, 2025
hf-kklein added a commit that referenced this pull request Apr 29, 2025
…ited SQLite table (not the `v_ahbtabellen` view) (#562)

* update database

https://github.com/Hochfrequenz/xml-migs-and-ahbs/releases/tag/v2025.04.12.9z

* Revert "feat(cache): Add Memory Caching In Format Versions Endpoint (#559)"

This reverts commit b56ec4b.

* read format version from Anwendungshandbuch tabelle

fixes Hochfrequenz/xml-fundamend-python#137
fixes #560

* better

* better docs

* prettier

---------

Co-authored-by: Konstantin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants