How to use the redis.createClient function in redis

To help you get started, we’ve selected a few redis 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 acruikshank / redis-waiting-list-demo / server.js View on Github external
applicationServer.listen( port );
  console.log( "Listening on port " + port );


  /*************************
   * Web Socket Communication
   *************************/

  // Initialize socket.io using redis store
  var io = sockets.listen( applicationServer );
  io.set( 'log level', 2 );

  // Use redis store to support multi-process/server communication
  var RedisStore = require('socket.io/lib/stores/redis');
  io.set('store', new RedisStore({
    redisPub : redis.createClient(),
    redisSub : redis.createClient(),
    redisClient : redis.createClient()
  }));

  function updateRoomCount( roomId ) {
    return participation.count(roomId, withCount);

    function withCount( err, count ) {
      if ( err )
        return console.log(err);

      io.sockets.in(roomId).json.emit('message', {count:count})
    }
  }

  // Use join message to register as a participant
github greasytortoise / alumConnect / server / config / middleware.js View on Github external
var bodyParser = require('body-parser');
var redisClient = require('redis').createClient();
var path = require('path');
var util = require('../lib/utility.js');
var multer  = require('multer');
var sharp = require('sharp');
const configWP = require('../../webpack.config.js');
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');

var memstorage = multer.memoryStorage();
var upload = multer({
  storage: memstorage,
  limits: { fileSize: 1 * 1000 * 500 }, // 500kb
});

var passport = require('passport');
github wyattjoh / rate-limit-redis / lib / redis-store.js View on Github external
var RedisStore = function(options) {
  options = defaults(options, {
    expiry: 60, // default expiry is one minute
    prefix: "rl:",
    resetExpiryOnChange: false,
    redisURL: undefined,
  });

  var expiryMs = Math.round(1000 * options.expiry);

  // create the client if one isn't provided
  options.client = options.client || redis.createClient(options.redisURL);

  var setExpire = function(replies, rdskey) {
    // if this is new or has no expiry
    if (options.resetExpiryOnChange || replies[0] === 1 || replies[1] === -1) {
      // then expire it after the timeout
      options.client.pexpire(rdskey, expiryMs);
      return expiryMs;
    } else {
      return replies[1];
    }
  };

  var processReplies = function(replies) {
    // in ioredis, every reply consists of an array [err, value].
    // We don't need the error here, and if we aren't dealing with an array,
    // nothing is changed.
github flatiron / resourceful / test / engines / redis.js View on Github external
engine.load = function (resourceful, data, callback) {
  var conn = redis.createClient();

  var stuff = [];
  data = data.forEach(function (r) {
    r = JSON.parse(JSON.stringify(r));
    r.id = r._id;
    delete r._id;
    stuff.push('resourceful:' + engine.options.namespace + ':id:' + r.id);
    stuff.push(JSON.stringify(r));
  });

  conn.flushdb(function() {
    conn.mset(stuff, callback);
  });
};
github andyet / thoonk.js / thoonk.js View on Github external
var Thoonk = function(host, port) {
    EventEmitter.call(this);
    this.setMaxListeners(1000);


    this.host = host || 'localhost';
    this.port = port || 6379;
    this.redis = redis.createClient(this.port, this.host);
    this.lredis = redis.createClient(this.port, this.host);
    this.ready = false;

    this.lredis.on('message', function(channel, msg) {
        msg = msg.toString();
        this.emit(channel, channel, msg);
    }.bind(this));

    this.lredis.on('subscribe', function(channel) {
        this.emit('subscribed.' + channel);
    }.bind(this));

    this.scripts = {};
    this.shas = {};

    this.instance = uuid();
github unhosted / libredocs / users / handler.js View on Github external
function initRedis(cb) {
    console.log('initing redis');
    redisClient = redis.createClient(userDb.port, userDb.host);
    redisClient.on("error", function (err) {
      console.log("error event - " + redisClient.host + ":" + redisClient.port + " - " + err);
    });
    redisClient.auth(userDb.pwd, function() {
       console.log('redis auth done');
       //redisClient.stream.on('connect', cb);
       cb();
    });
  }
  function browseridVerify(obj, cb) {
github tcdl / msb / lib / adapters / redis.js View on Github external
queue.Subscribe = function(config) {
    subscriberClient = subscriberClient || redis.createClient(config.port, config.host, config.options);
    subscriberClient.setMaxListeners(0);

    var emitter = new EventEmitter();

    function onClientMessage(channel, message) {
      if (channel !== config.channel) return;
      process.nextTick(function() {
        var parsedMessage;
        try {
          parsedMessage = JSON.parse(message);
        } catch (e) {
          emitter.emit('error', e);
          return;
        }
        emitter.emit('message', parsedMessage);
      });
github ClickSimply / Nano-SQL / packages / Adapter-Redis / index.js View on Github external
utilities_1.fastCHAIN(Object.keys(_this._pkKey), function (item, i, next) {
                            _this._dbClients[item] = redis.createClient(_this.connectArgs);
                            _this._dbClients[item].on("ready", function () {
                                _this._dbClients[item].select(_this._DBIds[item], next);
                            });
                        }).then(function () {
                            getIndexes();
github UlordChain / ulord-node-stratum-pool / libs / stats.js View on Github external
function setupStatsRedis(){
        redisStats = redis.createClient(portalConfig.redis.port, portalConfig.redis.host);
        if(portalConfig.redis.password){
        	redisStats.auth(portalConfig.redis.password);
        };
    }
github dfoderick / bitshovel / shovelcache.js View on Github external
let start = function start() {
    cache = redis.createClient()
}