Skip to content

Commit

Permalink
feat(ruby): cache versions list 15 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Jan 22, 2019
1 parent c2f18e4 commit 74ec520
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/datasource/ruby-version/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ module.exports = {
const rubyVersionsUrl = 'https://www.ruby-lang.org/en/downloads/releases/';

async function getPkgReleases() {
// First check the persistent cache
const cacheNamespace = 'datasource-ruby-version';
const cachedResult = await renovateCache.get(cacheNamespace, 'all');
// istanbul ignore if
if (cachedResult) {
return cachedResult;
}
try {
const res = {
homepage: 'https://ruby-lang.org',
Expand All @@ -33,6 +40,7 @@ async function getPkgReleases() {
}
}
}
await renovateCache.set(cacheNamespace, 'all', res, 15);
return res;
} catch (err) {
if (err && (err.statusCode === 404 || err.code === 'ENOTFOUND')) {
Expand Down
1 change: 1 addition & 0 deletions test/datasource/ruby-version.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const rubyReleasesHtml = fs.readFileSync(

describe('datasource/gradle', () => {
describe('getPkgReleases', () => {
beforeEach(() => global.renovateCache.rmAll());
it('parses real data', async () => {
got.mockReturnValueOnce({
body: rubyReleasesHtml,
Expand Down

0 comments on commit 74ec520

Please sign in to comment.