Skip to content

Commit

Permalink
prometheus: route to reset cache
Browse files Browse the repository at this point in the history
  • Loading branch information
andersonba committed Oct 29, 2019
1 parent 0cdbec4 commit b966dbd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions prometheus/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ app.get(Settings.path, async (req, res, next) => {

app.get('/check', (_, res) => res.send('OK'));

app.delete('/cache', (_, res) => {
store.clear();
res.send('Cache cleared!');
});

const server = app.listen(env('PORT', 3000), () => {
configureTimer();
console.log('Server listening on port %d', server.address().port);
Expand Down
5 changes: 5 additions & 0 deletions prometheus/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class Store {
get(key) {
return this.cache.get(key) || this.data[key];
}

clear() {
this.data = {};
this.cache.flush();
}
}

module.exports = Store;

0 comments on commit b966dbd

Please sign in to comment.