Add script for clearing the cache
This commit is contained in:
parent
f0d05ea756
commit
f138748d1a
|
@ -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();
|
||||
});
|
Loading…
Reference in New Issue