Sets the Redis instance to use.

@param Redis $redis
182412
public function setRedis(\Redis $redis)
    {
        $redis->setOption(Redis::OPT_SERIALIZER, $this->getSerializerValue());
        $this->_redis = $redis;
    }
867533
public function set($key, $value, $ttl)
    {
        // if no ttl is provided use the default
        if (is_null($ttl)) $ttl = $this->config->get('expiration');
        return (bool) $this->redis->pipeline(function($pipe) use ($key, $value, $ttl) {
            $pipe->set($key, $value);
            $pipe->expire($key, $ttl);
        });
    }
1072244
public function configure(Redis $redis, OptionsBag $conn)
    {
        if ($conn['persistent']) {
            $redis->pconnect($conn['host'], $conn['port'], $conn['timeout']);
        } else {
            $redis->connect($conn['host'], $conn['port'], $conn['timeout'], $conn['retry_interval']);
        }

        if ($conn['password']) {
            $redis->auth($conn['password']);
        }

        if ($conn['database'] >= 0) {
            $redis->select($conn['database']);
        }

        if ($conn['prefix']) {
            $redis->setOption(Redis::OPT_PREFIX, $conn['prefix']);
        }

        return $redis;
    }
1155216
public function connect() {
		if (!$this->_connect()) {
			throw new RedisSourceException(__d('redis', 'Could not connect.'));
		}

		if (!$this->_authenticate()) {
			throw new RedisSourceException(__d('redis', 'Could not authenticate.'));
		}

		if (!$this->_select()) {
			throw new RedisSourceException(__d('redis', 'Could not select.'));
		}

		if (!$this->_setPrefix()) {
			throw new RedisSourceException(__d('redis', 'Could not set prefix.'));
		}

		$this->connected = true;

		return $this->connected;
	}
1109374
public function offsetSet($offset, $value)
    {
        if ($offset === null) {
            $offset = uniqid('uid');
        }
        if (is_string($value)) {
            $this->redis->set($this->getStorageKey($offset), "!".$value);
        } else {
            $this->redis->set($this->getStorageKey($offset), serialize($value));
        }
    }
678095
def setup(self, redis_conn=None, host='localhost', port=6379):
        '''
        
        '''
        if redis_conn is None:
            if host is not None and port is not None:
                self.redis_conn = redis.Redis(host=host, port=port)
            else:
                raise Exception("Please specify some form of connection "
                                    "to Redis")
        else:
            self.redis_conn = redis_conn

        self.redis_conn.info()
825079
protected function _set()
	{
		// get the key for the cache identifier
		$key = $this->_get_key();

		// write the cache
		static::$redis->set($key, $this->prep_contents());
		if ( ! empty($this->expiration))
		{
			static::$redis->expireat($key, $this->expiration);
		}

		// update the index
		$this->_update_index($key);

		return true;
	}
497685
public function setRedirectUrl($redirectUrl = '')
    {
        $this->redirectUrl = $redirectUrl;
        $this->debug->debug(__FUNCTION__, 'setRedirectUrl: ' . json_encode($this->redirectUrl));

        return $this;
    }
1196974
def set(self, id, value):
        
        id = self.key_name(id)
        self.redis.set(id, json_dumps(value))
188985
def init(key, value)
      with_failure_grace(value) {
        @redis.set(key, value) if get(key, nil).nil?
      }
    end
40380
public function set(string $uri, string $query, EsiResponse $data)
    {

        $this->redis->set($this->buildCacheKey($uri, $query), serialize($data));
    }
562034
public function set($key, $value)
    {
        if (!is_array($value)) {
            throw new InvalidValueException(['the settings of `:key` key value must be array', 'key' => $key]);
        }

        $redis = is_object($this->_redis) ? $this->_redis : $this->_getRedis();
        $redis->set($this->_prefix . $key, json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));

        return $this;
    }
175263
def set_session_value(self, name, value):
        """"""

        self.redis().hset(self._session_key, name, value)
        self._update_session_expiration()
402732
protected function initInstances()
    {
        if (empty($this->instances)) {
            foreach ($this->servers as $server) {
                if ($server instanceof \Redis) {
                    if ($server->isConnected()) {
                        $redis = $server;
                    } else {
                        throw new \InvalidArgumentException("If you use \\Redis objects as argument, the object must be connected.");
                    }
                } else {
                    if (empty($server[0])) {
                        throw new \InvalidArgumentException("A server hostname or IP is required");
                    }

                    if (empty($server[1])) {
                        $server[1] = 6379;
                    }
                    if (empty($server[2])) {
                        $server[2] = 0;
                    }
                    list($host, $port, $timeout) = $server;
                    $redis = new \Redis();
                    $redis->connect($host, $port, $timeout);
                }
                $this->instances[] = $redis;
            }
        }
    }
1296490
public function setTtl($key, $ttl) {
        $redis = $this->_getRedisClient();
        $redis->expire($this->_getInternalKey($key), $ttl);
    }
122116
protected function setSessionConfiguration()
    {
        if (! $this->supportsSessions
            || $this->config->get('session.driver') !== 'redis-sentinel'
            || $this->config->get('session.connection') !== null
        ) {
            return;
        }

        $this->setConfigurationFor('session.connection', false);
    }
1064117
public function setValue($value): RedisCache
    {
        $redisclient = $this->getRedisConfig()->__invoke();
        $RedisData = (new RedisData())
            ->setData($value);
        $this->value = serialize($RedisData);
        $redisclient->setex($this->getKey(), $this->getExpire(), $this->getValue());

        return $this;
    }