Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function startAllConnections() {
try {
myUtils.validateConfig();
}
catch(e) {
console.error(e.message);
process.exit(2);
}
// redefine keys method before connections are started
if (config.get('redis.useScan')) {
console.log('Using scan instead of keys');
Object.defineProperty(Redis.prototype, 'keys', {
value: function(pattern, cb) {
let keys = [];
let that = this;
let scanCB = function(err, res) {
if (err) {
if (typeof cb === 'function') cb(err);
else {
console.log('ERROR in redefined "keys" function to use "scan" instead without callback: ' +
(err.message ? err.message : JSON.stringify(err)));
}
}
else {
let count = res[0], curKeys = res[1];
console.log("scanning: " + count + ": " + curKeys.length);
keys = keys.concat(curKeys);
if (Number(count) === 0) {
import Redis from 'ioredis'
import { redisLogger } from './logger'
import config from '../config'
const redis = new Redis(config.redis)
const { sendCommand } = Redis.prototype
Redis.prototype.sendCommand = async function (...options: any[]) {
const response = await sendCommand.call(this, ...options);
redisLogger.info(options[0].name, {
...options[0],
response
})
return response
}
export { redis }
import Redis from 'ioredis'
import { redisLogger } from './logger'
import config from '../config'
const redis = new Redis(config.redis)
const { sendCommand } = Redis.prototype
Redis.prototype.sendCommand = async function (...options: any[]) {
const response = await sendCommand.call(this, ...options);
redisLogger.info(options[0].name, {
...options[0],
response
})
return response
}
export { redis }
if (!(timeline instanceof Perf)) {
debug(
'Timeline passed to plugins/ioredis.wrap not an instance of performance-node. Skipping.'
);
return false;
}
if (!Redis.__iopipeShimmer) {
if (process.env.IOPIPE_TRACE_IOREDIS_INITPROMISE) {
shimmer.wrap(
Redis.Command && Redis.Command.prototype,
'initPromise',
wrapPromise
);
}
shimmer.wrap(Redis && Redis.prototype, 'sendCommand', wrapSendCommand);
Redis.__iopipeShimmer = true;
}
return true;
function wrapPromise(original) {
return function wrappedPromise() {
const command = this;
const cb = this.callback;
const id = createId();
const { name } = command;
data[id] = {
name,
dbType: 'Redis',
request: filterRequest(command)
};