mirror of
https://github.com/gitpod-io/gitpod.git
synced 2025-12-08 17:36:30 +00:00
[server] Fix caching of GitHub requests by using proper key
This commit is contained in:
parent
4dd9d0a167
commit
057947d6c5
@ -266,7 +266,7 @@ export class GitHubRestApi {
|
|||||||
user: User,
|
user: User,
|
||||||
params: RestEndpointMethodTypes["repos"]["get"]["parameters"],
|
params: RestEndpointMethodTypes["repos"]["get"]["parameters"],
|
||||||
): Promise<Repository> {
|
): Promise<Repository> {
|
||||||
const key = `getRepository:${params.owner}/${params.owner}:${user.id}`;
|
const key = `getRepository:${params.owner}/${params.repo}:${user.id}`;
|
||||||
const response = await this.runWithCache(key, user, (api) => api.repos.get(params));
|
const response = await this.runWithCache(key, user, (api) => api.repos.get(params));
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
@ -275,7 +275,7 @@ export class GitHubRestApi {
|
|||||||
user: User,
|
user: User,
|
||||||
params: RestEndpointMethodTypes["repos"]["getBranch"]["parameters"],
|
params: RestEndpointMethodTypes["repos"]["getBranch"]["parameters"],
|
||||||
): Promise<Branch> {
|
): Promise<Branch> {
|
||||||
const key = `getBranch:${params.owner}/${params.owner}/${params.branch}:${user.id}`;
|
const key = `getBranch:${params.owner}/${params.repo}/${params.branch}:${user.id}`;
|
||||||
const getBranchResponse = (await this.runWithCache(key, user, (api) =>
|
const getBranchResponse = (await this.runWithCache(key, user, (api) =>
|
||||||
api.repos.getBranch(params),
|
api.repos.getBranch(params),
|
||||||
)) as RestEndpointMethodTypes["repos"]["getBranch"]["response"];
|
)) as RestEndpointMethodTypes["repos"]["getBranch"]["response"];
|
||||||
@ -298,7 +298,7 @@ export class GitHubRestApi {
|
|||||||
user: User,
|
user: User,
|
||||||
params: RestEndpointMethodTypes["repos"]["listBranches"]["parameters"],
|
params: RestEndpointMethodTypes["repos"]["listBranches"]["parameters"],
|
||||||
): Promise<Branch[]> {
|
): Promise<Branch[]> {
|
||||||
const key = `getBranches:${params.owner}/${params.owner}:${user.id}`;
|
const key = `getBranches:${params.owner}/${params.repo}:${user.id}`;
|
||||||
const listBranchesResponse = (await this.runWithCache(key, user, (api) =>
|
const listBranchesResponse = (await this.runWithCache(key, user, (api) =>
|
||||||
api.repos.listBranches(params),
|
api.repos.listBranches(params),
|
||||||
)) as RestEndpointMethodTypes["repos"]["listBranches"]["response"];
|
)) as RestEndpointMethodTypes["repos"]["listBranches"]["response"];
|
||||||
@ -311,7 +311,7 @@ export class GitHubRestApi {
|
|||||||
} = branch;
|
} = branch;
|
||||||
const commit = await this.getCommit(user, { ...params, ref: sha });
|
const commit = await this.getCommit(user, { ...params, ref: sha });
|
||||||
|
|
||||||
const key = `getBranch:${params.owner}/${params.owner}/${params.branch}:${user.id}`;
|
const key = `getBranch:${params.owner}/${params.repo}/${params.branch}:${user.id}`;
|
||||||
const getBranchResponse = (await this.runWithCache(key, user, (api) =>
|
const getBranchResponse = (await this.runWithCache(key, user, (api) =>
|
||||||
api.repos.listBranches(params),
|
api.repos.listBranches(params),
|
||||||
)) as RestEndpointMethodTypes["repos"]["getBranch"]["response"];
|
)) as RestEndpointMethodTypes["repos"]["getBranch"]["response"];
|
||||||
@ -331,7 +331,7 @@ export class GitHubRestApi {
|
|||||||
user: User,
|
user: User,
|
||||||
params: RestEndpointMethodTypes["repos"]["getCommit"]["parameters"],
|
params: RestEndpointMethodTypes["repos"]["getCommit"]["parameters"],
|
||||||
): Promise<CommitInfo> {
|
): Promise<CommitInfo> {
|
||||||
const key = `getCommit:${params.owner}/${params.owner}/${params.ref}:${user.id}`;
|
const key = `getCommit:${params.owner}/${params.repo}/${params.ref}:${user.id}`;
|
||||||
const getCommitResponse = (await this.runWithCache(key, user, (api) =>
|
const getCommitResponse = (await this.runWithCache(key, user, (api) =>
|
||||||
api.repos.getCommit(params),
|
api.repos.getCommit(params),
|
||||||
)) as RestEndpointMethodTypes["repos"]["getCommit"]["response"];
|
)) as RestEndpointMethodTypes["repos"]["getCommit"]["response"];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user