Add script for clearing the cache

This commit is contained in:
Michael Jackson 2018-09-03 10:54:17 -07:00
parent f0d05ea756
commit f138748d1a
1 changed files with 25 additions and 0 deletions

25
scripts/clear-cache.js Normal file
View File

@ -0,0 +1,25 @@
const cache = require("../modules/utils/cache");
function getKeys(client, pattern, callback, array = [], cursor = 0) {
client.scan(cursor, "MATCH", pattern, (error, reply) => {
if (error) {
reject(error);
} else {
const next = reply[0];
const keys = reply[1];
array.push.apply(array, keys);
if (next == 0) {
callback(array);
} else {
getKeys(client, pattern, callback, array, next);
}
}
});
}
getKeys(cache, "npmPackageInfo-*", keys => {
console.log(keys);
process.exit();
});