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

Cached api controller pipelines #19880

Conversation

allouis
Copy link
Contributor

@allouis allouis commented Mar 18, 2024

ref ENG-761
ref https://linear.app/tryghost/issue/ENG-761

Creating these pipelines is expensive, and we don't want to do it repeatedly for the same controller. Adding caching should reduce the amount of time spent setting up pipelines for each usage of the get helper.

ref ENG-761
ref https://linear.app/tryghost/issue/ENG-761

Creating these pipelines is expensive, and we don't want to do it repeatedly
for the same controller. Adding caching should reduce the amount of time spent
setting up pipelines for each usage of the `get` helper.
@@ -267,6 +273,10 @@ const pipeline = (apiController, apiUtils, apiType) => {
Object.assign(obj[method], apiImpl);
return obj;
}, {});

controllerMap.set(apiController, result);
Copy link
Member

Choose a reason for hiding this comment

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

Would it be worth using docName as the key?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

docName isn't unique - so no! 😝

Copy link
Member

Choose a reason for hiding this comment

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

wtf

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One of the things docName is used for is to determine which permissions to use - so the pages endpoint has a docName of 'posts' - as does the postsPublic endpoint

Copy link
Member

Choose a reason for hiding this comment

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

unbelievable

@allouis allouis merged commit 3f27ca5 into main Mar 18, 2024
20 checks passed
@allouis allouis deleted the egg-eng-761-api-pipeline-is-cpu-intensive-and-created-on-the-fly-2 branch March 18, 2024 17:29
royalfig pushed a commit that referenced this pull request Mar 25, 2024
ref ENG-761
ref https://linear.app/tryghost/issue/ENG-761

Creating these pipelines is expensive, and we don't want to do it
repeatedly for the same controller. Adding caching should reduce the
amount of time spent setting up pipelines for each usage of the `get`
helper.
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.

None yet

2 participants