From b966dbd1f402dc0d5c865d0de52e5a9a030336c8 Mon Sep 17 00:00:00 2001 From: Anderson de Oliveira Date: Tue, 29 Oct 2019 20:00:02 +0000 Subject: [PATCH] prometheus: route to reset cache --- prometheus/index.js | 5 +++++ prometheus/store.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/prometheus/index.js b/prometheus/index.js index cf7afc2..0c84d9d 100644 --- a/prometheus/index.js +++ b/prometheus/index.js @@ -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); diff --git a/prometheus/store.js b/prometheus/store.js index caeab46..2b0f036 100644 --- a/prometheus/store.js +++ b/prometheus/store.js @@ -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;