Returns the current Redis connection. If none has been created, will
 create a new one.
480067
def redis
      @redis ||= (
        url = URI(@redis_url || ENV["REDIS_URL"] || "redis://127.0.0.1:6379/0")

        ::Redis.new({
          :host => url.host,
          :port => url.port,
          :db => url.path[1..-1],
          :password => url.password
        })
      )
    end
125692
def refresh(self, using=None, **kwargs):
        
        return self._get_connection(using).indices.refresh(index=self._name, **kwargs)
385425
def get_default_connection():
  
  tid = id(threading.current_thread())
  conn = _conn_holder.get(tid)
  if not conn:
    with(_rlock):
      # No other thread would insert a value in our slot, so no need
      # to recheck existence inside the lock.
      if 'project_endpoint' not in _options and 'project_id' not in _options:
        _options['project_endpoint'] = helper.get_project_endpoint_from_env()
      if 'credentials' not in _options:
        _options['credentials'] = helper.get_credentials_from_env()
      # We still need the lock when caching the thread local connection so we
      # don't race with _conn_holder.clear() in set_options().
      _conn_holder[tid] = conn = connection.Datastore(**_options)
  return conn
801044
def redis(self):
        
        redis_url = current_app.config.get("SSE_REDIS_URL")
        if not redis_url:
            redis_url = current_app.config.get("REDIS_URL")
        if not redis_url:
            raise KeyError("Must set a redis connection URL in app config.")
        return StrictRedis.from_url(redis_url)
147714
public function getConnection()
    {
        if (null === $this->connection) {
            $this->connection = new \Redis();

            if (!$this->connection->pconnect(
                $this->config['default']['host'],
                $this->config['default']['port']
            )) {
                throw new \RedisException('Unable to connect');
            }
        }

        return $this->connection;
    }
827468
async def _call_redis(self, meth, *args, **kwargs):
        """"""
        while True:
            try:
                if not self._redis:
                    self._redis = await self._make_connection()
                return await meth(self._redis, *args, **kwargs)
            except aioredis.RedisError:
                logger.exception("Redis connection error")
                if self._redis:
                    self._redis.close()
                    await self._redis.wait_closed()
                    self._redis = None
                await asyncio.sleep(3)
915642
Jedis getConnection()
    {
        if (logger.isDebugEnabled())
            logger.info("borrowing connection from pool");
        Object poolOrConnection = getConnectionPoolOrConnection();
        if (poolOrConnection != null && poolOrConnection instanceof JedisPool)
        {

            Jedis connection = ((JedisPool) getConnectionPoolOrConnection()).getResource();
            connection.getClient().setTimeoutInfinite();
            Map props = RedisPropertyReader.rsmd.getProperties();

            // set external xml properties.
            if (props != null)
            {
                // props.
                for (Object key : props.keySet())
                {
                    connection.configSet(key.toString(), props.get(key).toString());
                }
            }
            return connection;
            
        }
        else
        {
            PersistenceUnitMetadata puMetadata = kunderaMetadata.getApplicationMetadata().getPersistenceUnitMetadata(
                    getPersistenceUnit());

            Properties props = puMetadata.getProperties();
            String contactNode = null;
            String defaultPort = null;
            String password = null;
            if (externalProperties != null)
            {
                contactNode = (String) externalProperties.get(PersistenceProperties.KUNDERA_NODES);
                defaultPort = (String) externalProperties.get(PersistenceProperties.KUNDERA_PORT);
                password = (String) externalProperties.get(PersistenceProperties.KUNDERA_PASSWORD);
            }

            if (contactNode == null)
            {
                contactNode = RedisPropertyReader.rsmd.getHost() != null ? RedisPropertyReader.rsmd.getHost()
                        : (String) props.get(PersistenceProperties.KUNDERA_NODES);
            }
            if (defaultPort == null)
            {
                defaultPort = RedisPropertyReader.rsmd.getPort() != null ? RedisPropertyReader.rsmd.getPort()
                        : (String) props.get(PersistenceProperties.KUNDERA_PORT);
            }
            if (password == null)
            {
                password = RedisPropertyReader.rsmd.getPassword() != null ? RedisPropertyReader.rsmd.getPassword()
                        : (String) props.get(PersistenceProperties.KUNDERA_PASSWORD);
            }
            if (defaultPort == null || !StringUtils.isNumeric(defaultPort))
            {
                throw new RuntimeException("Invalid port provided: " + defaultPort);
            }
            Jedis connection = new Jedis(contactNode, Integer.parseInt(defaultPort));

            if (password != null)
            {
                connection.auth(password);
            }
            connection.connect();
            return connection;
        }
    }
588682
public function getSlaveConnection()
    {
        if (null === $this->slaveConnection) {
            $this->slaveConnection = new \Redis();
            $this->slaveConnection->pconnect(
                $this->config['slave']['HOST'],
                $this->config['slave']['PORT']
            );
        }
        return $this->slaveConnection;
    }
681498
def _redis_client(opts):
    '''
    
    '''
    redis_host = opts.get("eauth_redis_host", "localhost")
    redis_port = opts.get("eauth_redis_port", 6379)
    try:
        return rediscluster.StrictRedisCluster(host=redis_host, port=redis_port, decode_responses=True)
    except rediscluster.exceptions.RedisClusterException as err:
        log.warning(
            'Failed to connect to redis at %s:%s - %s',
            redis_host, redis_port, err
        )
        return None
1233137
def reconnect_redis(self):
        '''
        '''

        if self.shared_client and Storage.storage:
            return Storage.storage

        storage = Redis(
            port=self.context.config.REDIS_RESULT_STORAGE_SERVER_PORT,
            host=self.context.config.REDIS_RESULT_STORAGE_SERVER_HOST,
            db=self.context.config.REDIS_RESULT_STORAGE_SERVER_DB,
            password=self.context.config.REDIS_RESULT_STORAGE_SERVER_PASSWORD
        )

        if self.shared_client:
            Storage.storage = storage
        return storage
269442
def get_connection(name='default', use_strict_redis=False):
    
    from .settings import QUEUES
    return get_redis_connection(QUEUES[name], use_strict_redis)
880637
public static function redis()
    {
        // Detect when the PID of the current process has changed (from a fork, etc)
        // and force a reconnect to redis.
        $pid = getmypid();
        if (self::$pid !== $pid) {
            self::$redis = null;
            self::$pid   = $pid;
        }

        if(!is_null(self::$redis)) {
            return self::$redis;
        }

        $server = self::$redisServer;
        if (empty($server)) {
            $server = 'localhost:6379';
        }

        if(is_array($server)) {
            self::$redis = new RedisCluster($server);
        } else {
            if (strpos($server, 'unix:') === false) {
                list($host, $port) = explode(':', $server);
            } else {
                // $server is 'unix:/tmp/redis.sock'
                $host = $server;
                $port = null;
            }
            self::$redis = new Redis($host, $port);
            if (!empty(self::$redisPassword)) {
                self::$redis->auth(self::$redisPassword);
            }
        }

        self::$redis->select(self::$redisDatabase);
        return self::$redis;
    }
1351359
public function getRedis(): ?Connection
    {
        if (!$this->hasRedis()) {
            $this->setRedis($this->getDefaultRedis());
        }
        return $this->redis;
    }
1240877
def create_redis_client(self):
        """"""
        return ray.services.create_redis_client(
            self._redis_address, self._ray_params.redis_password)
794175
def _ReturnConnection(self):
		
		if self.conn is not None:
			if self.connInfo.commitOnEnd is True or self.commitOnEnd is True:
				self.conn.Commit()
					
			Pool().returnConnection(self.conn)
			self.conn = None
930461
def _new_conn(self):
        
        self.num_connections += 1
        log.debug("Starting new HTTP connection (%d): %s",
                  self.num_connections, self.host)

        conn = self.ConnectionCls(host=self.host, port=self.port,
                                  timeout=self.timeout.connect_timeout,
                                  strict=self.strict, **self.conn_kw)
        return conn
1090396
def make_connection(self):
        ""
        if self._created_connections >= self.max_connections:
            raise ConnectionError("Too many connections")
        self._created_connections += 1
        return self.connection_class(**self.connection_kwargs)