How to use the ioredis.prototype function in ioredis

To help you get started, we’ve selected a few ioredis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joeferner / redis-commander / bin / redis-commander.js View on Github external
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) {
github shfshanyue / apollo-server-starter / lib / redis.ts View on Github external
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 }
github shfshanyue / apollo-server-starter / lib / redis.ts View on Github external
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 }
github iopipe / iopipe-js-trace / src / plugins / ioredis.js View on Github external
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)
      };

ioredis

A robust, performance-focused and full-featured Redis client for Node.js.

MIT
Latest version published 2 days ago

Package Health Score

90 / 100
Full package analysis