CartoDB-SQL-API/test/support/redis_utils.js

25 lines
688 B
JavaScript
Raw Normal View History

'use strict';
var redisConfig = {
host: global.settings.redis_host,
port: global.settings.redis_port,
max: global.settings.redisPool,
idleTimeoutMillis: global.settings.redisIdleTimeoutMillis,
reapIntervalMillis: global.settings.redisReapIntervalMillis
};
var metadataBackend = require('cartodb-redis')(redisConfig);
module.exports.clean = function clean(pattern, callback) {
metadataBackend.redisCmd(5, 'KEYS', [ pattern ], function (err, keys) {
if (err) {
return callback(err);
}
2016-09-12 22:00:33 +08:00
if (!keys || !keys.length) {
return callback();
}
metadataBackend.redisCmd(5, 'DEL', keys, callback);
});
};