CartoDB-SQL-API/test/support/redis-utils.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

'use strict';
2016-10-17 21:02:34 +08:00
var RedisPool = require('redis-mpool');
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);
2019-12-24 01:19:08 +08:00
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);
});
};
2016-08-01 17:48:11 +08:00
2019-12-24 01:19:08 +08:00
module.exports.getConfig = function getConfig () {
2016-08-01 17:48:11 +08:00
return redisConfig;
};
2016-10-17 21:02:34 +08:00
var pool = new RedisPool(redisConfig);
2019-12-24 01:19:08 +08:00
module.exports.getPool = function getPool () {
2016-10-17 21:02:34 +08:00
return pool;
};
2019-12-24 01:19:08 +08:00
module.exports.configureUserMetadata = function configureUserMetadata (action, params, callback) {
metadataBackend.redisCmd(5, action, params, callback);
2019-12-24 01:19:08 +08:00
};