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

Cache GitLab responses to avoid spamming the GitLab server #126

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dejan9393
Copy link

Fixes #125

@dejan9393 dejan9393 force-pushed the #125-cache-gitlab-api-promises branch from 6261a7b to 4322309 Compare March 10, 2021 05:12

private static _generateKeyHash(username: string, password: string) {
const sha = Crypto.createHash('sha256');
sha.update(JSON.stringify({ username: username, password: password }));

Choose a reason for hiding this comment

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

Tip: You can directly use sha.update(JSON.stringify({ username, password })); since username and password properties shares the same name...

Comment on lines 14 to 16
public static get DEFAULT_TTL() {
return 300;
}

Choose a reason for hiding this comment

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

Please excuse my question but why did you use a getter instead of public readonly DEFAULT_TTL = 300;?

Copy link
Author

Choose a reason for hiding this comment

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

Because this was basically a quick hackjob, copied from authcache.ts.

@dejan9393 dejan9393 force-pushed the #125-cache-gitlab-api-promises branch from 968e75d to 99c0119 Compare April 15, 2021 22:45
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.

GitLab API results are not cached, causes high CPU usage on GitLab server
2 participants