Skip to content
Snippets Groups Projects
Commit 960ef9b8 authored by Dmitry9's avatar Dmitry9 Committed by Rhys Arkins
Browse files

feat(Cargo): cache GitHub-cratesio-index requests for 10 minutes

parent 55829d01
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,15 @@ async function getPkgReleases({ lookupName }) { ...@@ -8,6 +8,15 @@ async function getPkgReleases({ lookupName }) {
if (!lookupName) { if (!lookupName) {
return null; return null;
} }
const cacheNamespace = 'cargo';
const cacheKey = lookupName;
const cachedResult = await renovateCache.get(cacheNamespace, cacheKey);
// istanbul ignore if
if (cachedResult) {
return cachedResult;
}
const len = lookupName.length; const len = lookupName.length;
let path; let path;
// Ignored because there is no way to test this without hitting up GitHub API // Ignored because there is no way to test this without hitting up GitHub API
...@@ -74,6 +83,9 @@ async function getPkgReleases({ lookupName }) { ...@@ -74,6 +83,9 @@ async function getPkgReleases({ lookupName }) {
} }
return release; return release;
}); });
const cacheMinutes = 10;
await renovateCache.set(cacheNamespace, cacheKey, result, cacheMinutes);
return result; return result;
} catch (err) { } catch (err) {
if (err.statusCode === 404 || err.code === 'ENOTFOUND') { if (err.statusCode === 404 || err.code === 'ENOTFOUND') {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment