/*
Create a new instance of this class.

@param {string} namespace
@param {object} RedisClient The redis client.
491321
function Session(config, RedisClient) {
      this.config = config;
      this.RedisClient = RedisClient;
      this.storeKey = __bind(this.storeKey, this);
      this.destroy = __bind(this.destroy, this);
      this.remove = __bind(this.remove, this);
      this.get = __bind(this.get, this);
      this.put = __bind(this.put, this);
      this.has = __bind(this.has, this);
      this.id = base64id.generateId();
      this.is_active = true;
    }
1113862
public void addNamespace(final MongoNamespace namespace) {
    this.instanceLock.writeLock().lock();
    try {
      if (this.nsStreamers.containsKey(namespace)) {
        return;
      }
      final NamespaceChangeStreamListener streamer =
          new NamespaceChangeStreamListener(
              namespace,
              instanceConfig.getNamespaceConfig(namespace),
              service,
              networkMonitor,
              authMonitor,
              getLockForNamespace(namespace));
      this.nsStreamers.put(namespace, streamer);
    } finally {
      this.instanceLock.writeLock().unlock();
    }
  }
1351953
function(key, dest, containerName) {

      // Attempt to connect to redis
      return getRedisClient()

      // Run the redis query and then quit
      .then(function(redis) {
        log.debug(format('Setting DNS. %s => %s', key, dest));
        return Promise.fromNode(function(cb) {
          redis.multi()
          .del(key)
          .rpush(key, containerName)
          .rpush(key, dest)
          .exec(cb);
        })
        .then(function() {
          redis.quit();
        });
      });

    }
478015
function uServicesManager(){

    var listenClient  = redis.createClient(config.redis[0].port, config.redis[0].server);

    client.publish('uServicesChannel', 'UPDATE');

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

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

    listenClient.subscribe('uServicesChannel');
}
1187898
def new_clients_for(*nodes)
      nodes.map do |node|
        host, port = node.split(':')
        opts = {:host => host, :port => port}
        opts.update(:db => @db) if @db
        opts.update(:password => @password) if @password
        client = Redis.new(@redis_client_options.merge(opts))
        if @namespace
          client = Redis::Namespace.new(@namespace, :redis => client)
        end
        @node_addresses[client] = node
        client
      end
    end
1013184
function $createClient(options) {
        /*
         * Ensure we have default options.
         */
        options = extend({}, {}, options);

        const { url, transport } = options;

        if (_clients[url]) {
            return _clients[url];
        }

        const client = mqtt.connect(url, transport);

        _clients[url] = client;

        return client;
    }
42150
function SimpleClient(options) {
    options = options || {};
    this.client = new Zookeeper(options);
    this.root = options.root || '/';
  }
815361
public static SoapClient create(String url, SoapProtocol protocol, String namespaceURI) {
		return new SoapClient(url, protocol, namespaceURI);
	}
1138225
function (namespaces, defaultNamespace, name) {
    var self = this;

    assert(namespaces);
    assert(name);
    if (/^\{.+\}/.test(name)) {
      return name;
    }
    else if (/:/.test(name)) {
      var parts = name.split(':');
      assert(parts.length === 2, parts);
      if (!namespaces[parts[0]]) {
        throw new xml2js.ValidationError("Unknown namespace " + parts[0] + ", name: " + name + ", known namespaces: " + util.inspect(namespaces, false, null));
      }
      return '{' + namespaces[parts[0]] + '}' + parts[1];
    }
    else if (defaultNamespace) {
      return '{' + defaultNamespace + '}' + name;
    }
    else {
      throw new xml2js.ValidationError("Unqualified name and no default namespace: " + name);
    }
  }
459722
function insertProxy(proxies, namespace, serverType, proxy) {
    proxies[namespace] = proxies[namespace] || {};
    if (proxies[namespace][serverType]) {
        for (const attr in proxy) {
            if (proxy.hasOwnProperty(attr)) {
                proxies[namespace][serverType][attr] = proxy[attr];
            }
        }
    } else proxies[namespace][serverType] = proxy;
}
824703
def callback(self, filename, lines, **kwargs):
        """"""

        self._logger.debug('Redis transport called')

        timestamp = self.get_timestamp(**kwargs)
        if kwargs.get('timestamp', False):
            del kwargs['timestamp']

        namespaces = self._beaver_config.get_field('redis_namespace', filename)
        if not namespaces:
            namespaces = self._namespace
        namespaces = namespaces.split(",")

        self._logger.debug('Got namespaces: '.join(namespaces))

        data_type = self._data_type
        self._logger.debug('Got data type: ' + data_type)

        server = self._get_next_server()
        self._logger.debug('Got redis server: ' + server['url'])

        pipeline = server['redis'].pipeline(transaction=False)

        callback_map = {
            self.LIST_DATA_TYPE: pipeline.rpush,
            self.CHANNEL_DATA_TYPE: pipeline.publish,
        }
        callback_method = callback_map[data_type]

        for line in lines:
            for namespace in namespaces:
                callback_method(
                    namespace.strip(),
                    self.format(filename, line, timestamp, **kwargs)
                )

        try:
            pipeline.execute()
        except redis.exceptions.RedisError, exception:
            self._logger.warn('Cannot push lines to redis server: ' + server['url'])
            raise TransportException(exception)
163726
function (namespace, extendSettings) {

    if (typeof namespace !== 'string' || !namespace.trim().length) {
      throw new Error('A valid string namespace is required as first parameter.');
    }

    namespace = namespace.trim();

    var settings = extend({}, globalSettings, extendSettings);
    var history = [];

    /**
     * Update instance settings.
     * @param  {Object} newSettings
     */
    this.update = function (newExtendSettings) {
      settings = extend({}, settings, newExtendSettings);
    };

    /**
     * Return settings.
     * @return {Object}
     */
    this.getSettings = function () {
      return extend({}, settings);
    };

    /**
     * Add a new method level to instance.
     * @param {Object} level - Level description.
     * @param {String} level.name - Level name.
     * @param {Number} [level.priority] - Number priority. Default to 3.
     * @param {String} [level.color] - The console color. Default `null`.
     */
     this.addLevel = function (level) {
      level = addLevel(level);
      this[level.name] = function () {
        this._execute(level, arguments);
      };
    };

    /**
     * Get a copy of the history. Meta objects are referenced.
     * @return {Array}
     */
    this.getHistory = function () {
      return history.map(function (item) {
        return extend({}, item);
      });
    };

    /**
     * Record a log in logger history if configured.
     * @private
     * @param  {Date} date - Date of log.
     * @param  {Object} level - Reference to the level definition.
     * @param  {String} text - The raw message.
     * @param  {Object} [meta] - Metadata.
     */
    this._record = function (date, level, text, meta) {
      if (settings.history) {
        var item = {
          date: date.getTime(),
          level: level.name,
          text: text,
        };
        if (meta) item.meta = meta;
        history.push(item);
      }
    };

    /**
     * Create a log description message by logger configuration.
     * @private
     * @param  {Date} date - Date of log.
     * @param  {Object} level - Reference to the level definition.
     * @return {String} - The description.
     */
    this._prefix = function (date, level) {

      var dtime = '';
      var dlevel = '';
      var dnamespace = '';

      if (settings.displayTime) {
        var hh = formatTime(date.getHours());
        var mm = formatTime(date.getMinutes());
        var ss = formatTime(date.getSeconds());
        var ms = formatTime(date.getMilliseconds(), 3);
        dtime = hh + ':' + mm + ':' + ss + '.' + ms + ' ';
      }

      if (settings.displayLevel) {
        dlevel = level.name.toUpperCase() +' ';
      }

      if (settings.displayNamespace) {
        dnamespace = '['+ namespace +'] ';
      }

      var dmsg = (dtime + dlevel + dnamespace).trim();
      dmsg = dmsg.length ? dmsg : '';

      return dmsg;
    };

    /**
     * Log the message in the console.
     * @private
     * @param  {Array} msgParts - Array of strings to log.
     */
    this._log = function (msgParts) {
      if (settings.display) {
        if (console && console.log) {
          console.log.apply(console.log, msgParts);
        }
      }
    };

    /**
     * Log method definition.
     * @private
     * @param  {Object} level - Reference to the level definition.
     * @param  {Array} args - The arguments received by the log method.
     */
    this._execute = function (level, args) {

      var date = new Date();
      var text = '';
      var meta = void 0;

      args = Array.prototype.slice.call(args, 0);
      for (var i=0; i<args.length; i++) {
        if (typeof args[i] === 'function') {
          // Functions are not used.
        } else if (i === args.length - 1 && Object(args[i]) === args[i]) {
          meta = args[i];
        } else {
          text += ' '+ args[i];
        }
      }
      text = text.trim();

      this._record(date, level, text, meta);

      if (settings.throwErrors && level.priority <= 0) {
        throw new Error(text);
      }

      if (level.priority <= settings.priority) {

        var prefix = this._prefix(date, level);
        var msgParts = [text];

        if (prefix.length) {
          if (settings.colors && level.color) {
            if (isNode) {
              msgParts = [level.color.node + prefix + NODE_COLOR_END +' '+ text];
            } else {
              msgParts = ['%c'+ prefix +' %c'+ text, level.color.browser, BROWSER_COLOR_END];
            }
          } else {
            msgParts = [prefix +' '+ text];
          }
        }

        this._log(msgParts);
      }
    };
  }
924150
function RedisTimeseriesStorage (options) {
    this.redisClient = options.redisClient;
    this.keyPrepend = "js:tss:";
    if (options.key) {
        this.keyPrepend += options.key+":";
    }
}
875005
private function _createInstance($namespace, $class, $params, $method_name, $data)
    {
        $ns_class = $namespace . $class;

        //create a reflection class so that we can pass parameters to the constructor

        $ref_class = new \ReflectionClass($ns_class);

        if (is_array($params) && sizeof($params) > 0) {

            $instance = $ref_class->newInstanceArgs($params);

        } else {

            $instance = new $ns_class();
        }
        
        $this->logger->info("$namespace object created for $class class");
   
        //call the method along with parameters, if they exist !
        if (method_exists($instance, $method_name))
        {
            if(is_callable(array($instance, $method_name)))
            {
                $last_hook = $this->loading[count($this->loading) - 1];
                $this->loaderHooks($instance,"pre_$last_hook",$class,$method_name,$data);
                call_user_func_array(array($instance, $method_name), $data);
                $this->loaderHooks($instance,"post_$last_hook",$class,$method_name,$data);
            }
        }elseif(is_object($instance)) 
        {
            $last_hook = $this->loading[count($this->loading) - 1];
            $this->loaderHooks($instance,"pre_$last_hook",$class,$method_name,$data);
        }
        else if(strpos($namespace,'controller') > 0)
        {
            header("HTTP/1.0 404 Not Found");
            Base::getInstance()->hook('404',array(
                'file' => $ref_class,
                'controller' => $class,
                'method' => $method_name,
                'message' => '404'
            ));
            die();
        }

        $this->clearCurrentLoader();

        return $instance;
    }
265486
public function setRedis(?RedisClient $redis = null)
    {
        if (! $redis) {
            $server = Arr::get($this->config, 'server', []);
            $options = Arr::get($this->config, 'options', []);

            // forbid setting prefix from options
            if (Arr::has($options, 'prefix')) {
                $options = Arr::except($options, 'prefix');
            }

            $redis = new RedisClient($server, $options);
        }

        $this->redis = $redis;
    }
1142170
public final void nameSpace (String namespace) {
    if (namespace == null || namespace.equals("")) {
      _namespace = "";
    } else {
      _namespace = namespace + ":";
    }
  }
632536
func NewClient(namespace string, pool *redis.Pool) *Client {
	return &Client{
		namespace: namespace,
		pool:      pool,
	}
}