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
Cached api controller pipelines #19880
Conversation
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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! 😝
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wtf
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unbelievable
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.