当抽取规则发生变化的时候
向Redis服务器Channel：pr发送消息CHANGE
从节点就会重新初始化抽取规则
766693
public void extractRegularChange() {
        String message = "CHANGE";
        Jedis jedis = jedisPool.getResource();
        jedis.publish("pr", message);
        jedisPool.returnResource(jedis);
    }
317259
function RedisStore(args) {
    args = args || {};
    var id = args.id;
    var self = {},
        host = args.host || getProp("CACHE_REDIS_HOST"),
        port = args.port || getProp("CACHE_REDIS_PORT");
    var ttl = args.ttl;
    self.name = 'redis';
    self.client = require('redis').createClient(port, host, args);
    self.id = id;

    var redisOptions = {
        redis_host: host,
        redis_port: port
    };

    var pool = new RedisPool(redisOptions),
        getKey = function (key) {
            return id + "__" + key;
        };

    function connect(cb) {
        pool.acquire(function (err, conn) {
            if (err) {
                pool.release(conn);
                return cb(err);
            }

            if (args.db || args.db === 0) {
                conn.select(args.db);
            }

            cb(null, conn);
        });
    }

    self.get = function (key, cb) {
        connect(function (err, conn) {
            if (err) {
                return cb(err);
            }

            conn.get(getKey(key), function (err, result) {
                pool.release(conn);
                if (err) {
                    return cb(err);
                }
                cb(null, JSON.parse(result));
            });
        });
    };

    self.set = function (key, value, cb) {
        connect(function (err, conn) {
            if (err) {
                return cb(err);
            }

            if (ttl) {
                conn.setex(getKey(key), ttl, JSON.stringify(value), function (err, result) {
                    pool.release(conn);
                    cb(err, result);
                });
            } else {
                conn.set(getKey(key), JSON.stringify(value), function (err, result) {
                    pool.release(conn);
                    cb(err, result);
                });
            }
        });
    };

    self.del = function (key, cb) {
        connect(function (err, conn) {
            if (err) {
                return cb(err);
            }

            conn.del(getKey(key), function (err, result) {
                pool.release(conn);
                cb(err, result);
            });
        });
    };

    self.reset = function (cb) {
        connect(function (err, conn) {
            if (err) {
                return cb(err);
            }

            conn.keys(self.id + "*", function (err, keys) {
                if (err) {
                    return cb(err);
                }
                //delete all keys
                keys.push(function (err, result) {
                    pool.release(conn);
                    cb(err, result);
                });
                conn.del.apply(conn, keys)
            });
        });
    };

    self.keys = function (cb) {
        connect(function (err, conn) {
            if (err) {
                return cb(err);
            }

            conn.keys(self.id + "*", function (err, keys) {
                if (err) {
                    return cb(err);
                }
                pool.release(conn);
                cb(err, keys);
            });
        });
    };

    return self;
}
566396
def request_change_variable_json(self, py_db, request, thread_id):
        '''
        
        '''
        py_db.post_method_as_internal_command(
            thread_id, internal_change_variable_json, request)
83585
function increment(redisClient, amount, keyPrepend, key, callback) {

    if (typeof amount !== 'number') {
        callback("increment amount is not number");
        return;
    }

    var multi = redisClient.multi();

    // Chain each redis command.
    incrementMinute(multi, amount, keyPrepend, key);
    incrementHour(multi, amount, keyPrepend, key);
    incrementDays(multi, amount, keyPrepend, key);
    incrementWeeks(multi, amount, keyPrepend, key);

    // Do it
    multi.exec(callback);

}
684609
public static ExtractRegular getInstance(String serverUrl, String redisHost, int redisPort) {
        if (extractRegular != null) {
            return extractRegular;
        }
        synchronized (ExtractRegular.class) {
            if (extractRegular == null) {
                extractRegular = new ExtractRegular();
                //订阅Redis服务器Channel：pr，当规则改变的时候会收到通知消息CHANGE并重新初始化规则集合
                extractRegular.subscribeRedis(redisHost, redisPort, serverUrl);
                //初始化抽取规则
                extractRegular.init(serverUrl);
            }
        }
        return extractRegular;
    }
93852
function uBrokersManager(){
    var listenClient  = redis.createClient(config.redis[0].port, config.redis[0].server);

    listenClient.on("error", function (err) {
        console.log("Redis listen error " + err);
    });

    listenClient.on('message', function(channel, message) {
        client.get('uBrokers', function(err, reply) {
            uBrokers = JSON.parse(reply);
        });
    });

    listenClient.subscribe('uBrokersChannel');
}
741284
function RedisIssueDao(client) {
	this.client = client;
	this.prefix = "omega:";

	console.log('storing issues in: redis://' + this.client.host + ':' + this.client.port + '/' + this.prefix);
}
966101
def refresh(self, *args, **kwargs):
        
        self.prjbrws.set_model(self.create_prj_model())
        if self.get_current_file():
            self.set_to_current()
        else:
            self.init_selection()
1276984
def save!(&block)
      fail StandardError, 'Cannot re-save a flow' if id
      self.id = SecureRandom.uuid
      record_id = redis_id + ':definition'
      self.created_at = Time.now.to_f

      # Actually save the record:
      redis.set record_id, serialize

      # Transition into the first phase:
      add_transition to: current_phase, timestamp: Time.now.utc.to_f

      # Add our id to the list of active flows:
      redis.sadd 'distribot.flows.active', id
      redis.incr('distribot.flows.running')

      # Announce our arrival to the rest of the system:
      Distribot.publish! 'distribot.flow.created', flow_id: id

      wait_for_flow_to_finish(block) if block_given?
      self
    end
645650
function Q(redis, preopts) {
  // handle forgetting a 'new'
  if (!(this instanceof Q)) {
    return new Q(redis, preopts);
  }

  if (preopts === undefined) preopts = redis, redis = preopts.redis;

  if (!redis && preopts.createRedis) {
    this._redis = redis = preopts.createRedis()
  } else {
    console.error('WARNING: passing a redis instance to relyq is deprecated. Please pass options.createRedis() function.')
    this._redis = redis
  }

  this._options = typeof preopts === 'string' ? {prefix: preopts, redis: redis} : preopts
  this._delimeter = preopts.delimeter || ':';

  this._idfield = preopts.idfield || 'id';
  this._prefix = preopts.prefix || preopts;
  this._clean_finish = preopts.clean_finish === undefined || preopts.clean_finish;
  this._keep_storage = preopts.clean_finish === 'keep_storage';

  this.todo = new simpleq.Q(redis, this._prefix + this._delimeter + 'todo');
  this.doing = new simpleq.Q(redis, this._prefix + this._delimeter + 'doing');
  this.failed = new simpleq.Q(redis, this._prefix + this._delimeter + 'failed');
  if (!this._clean_finish) {
    this.done = new simpleq.Q(redis, this._prefix + this._delimeter + 'done');
  }

  if (preopts.allow_defer && preopts.createRedis) {
    this.deferred = new DeferredTaskList(this, {
      polling_interval: preopts.defer_polling_interval,
      key: this._prefix + this._delimeter + 'deferred',
      redis: preopts.createRedis(),
    });
  }
  if (preopts.allow_recur && preopts.createRedis) {
    this.recurring = new RecurringTaskList(this, {
      polling_interval: preopts.recur_polling_interval,
      key: this._prefix + this._delimeter + 'recurring',
      redis: preopts.createRedis(),
    });
  }

  EventEmitter.call(this);

  var rq = this;
  if (this._redis.ready) {
    setImmediate(function () {
      rq.emit('ready')
    })
  } else {
    this._redis.once('ready', function () {
      rq.emit('ready')
    })
  }
}
1373867
def update_redis(project: str, environment: str, feature: str, state: str) \
        -> None:
    
    try:
        hosts = RedisWrapper.connection_string_parser(
            os.environ.get('REDIS_HOSTS'))
    except RuntimeError as ex:
        LOG.error(ex)
        sys.exit(1)

    for host in hosts:
        LOG.info("connecting to %s:%s", host.host, host.port)
        try:
            if valid_state(state):
                new_state = state.lower()
                redis = RedisWrapper(
                    host.host,
                    host.port,
                    project,
                    environment
                )
                redis.update_flag_record(new_state, feature)
                create_file(project, environment, feature, new_state)
                LOG.info("%s was successfully updated.", feature)
            else:
                raise Exception('Invalid state: {0}, -s needs \
                    to be either on or off.'.format(state))
        except KeyError as ex:
            LOG.error("unable to update %s. Exception: %s",
                      host.host,
                      ex)
            sys.exit(1)
1099265
function connectToRedis(db, opts) {

    // get the redis client
    var client = redis.createClient(opts.port, opts.host);

    // log any errors
    client.on('error', function (err) {
        redisOffline = true;
        console.log('connectToRedis error: ' + err);
    });

    client.on('ready', function () {
        redisOffline = false;
    });

    // if there is a password, do auth
    var deferred = Q.defer();
    if (opts.password) {
        client.auth(opts.password, function (authErr) {
            if (authErr) {
                deferred.reject(authErr);
                return;
            }

            client.select(db, function (err) {
                err ? deferred.reject(err) : deferred.resolve(client);
            });
        });
    }
    else {
        client.select(db, function (err) {
            err ? deferred.reject(err) : deferred.resolve(client);
        });
    }

    return deferred.promise;
}
701389
def publish(self):
        """"""
        while not self.ws.closed:
            # Sleep to prevent *constant* context-switches.
            gevent.sleep(self.lag_tolerance_secs)
            message = self.ws.receive()
            if message is not None:
                channel_name, data = message.split(":", 1)
                redis_conn.publish(channel_name, data)
367365
function createClient(redisClientOptions) {
  const client = redis.createClient(redisClientOptions);
  if (!client._options) {
    client._options = redisClientOptions;
  }
  return client;
}
1255536
public function connect(): \redis
    {
        //如果已经连接,返回连接句柄
        if ($this->handle) {
            return $this->handle;
        }

        // 记录开始时间
        $start = timeLog();

        // 取此集合的配置
        $config = $config = configDefault('', 'redis');
        if (!$config) {
            trigger_error('无法读取Redis配置文件(redis)', E_USER_ERROR);
        }

        //尝试连接,出错就抛异常吧
        $this->handle = new \redis();
        $success = $this->handle->connect($config['hostname'], $config['port']);
        if (!$success) {
            trigger_error('无法连接Redis服务器(' . $config['hostname'] . ':' . $config['port'] . ')', E_USER_ERROR);
        }

        //如果设置了密码,要通过AUTH
        if (isset($config['password']) and $config['password']) {
            //如果密码不正确,提示
            if (!$this->auth($config['password'])) {
                trigger_error('Redis服务器身份验证失败', E_USER_ERROR);
            }
        }

        // 记录调试信息
        debug("connect to redis {$config['hostname']} ,persist:" . timeLog($start) * 1000 . 'ms');
        return $this->handle;
    }
58809
function() {
      return Promise.retry(function() {
        log.debug(format('Connecting to redis on %s:%s', REDIS_IP, REDIS_PORT));
        return redis.createClient(REDIS_PORT, REDIS_IP);
      });
    }
1056756
function(err, results) {

        if (!err) {

          self.sessionSubscriber = new SessionSubscriber(
            self.conf && self.conf.redis && self.conf.redis ? self.conf.redis : undefined,
            self.serverName,
            function(err) {
              if (!err) {

                console.info(' (init) REDIS     is connected  (for pub/sub)');
                console.info('        REDIS     is subscribed (C-' + self.serverName + ')');

                self._startup(server, io);

                if (cb) cb();

              } else {
                console.error(err);
                process.exit(1);
              }
            }
          );

        } else {

          for (var errNum in results) {
            if (results.hasOwnProperty(errNum) && results[errNum]) {
              console.error('  - ' + results[errNum] + '\n');
            }
          }
          process.exit(1);
        }
      }