protected function parsePersistentId(array $connections, OptionsBag $options, OptionsBag $sessionOptions)
    {
        // Try based on save_path.
        $savePath = $sessionOptions['save_path'];
        $savePath = trim($savePath); // Just in case.
        if ($savePath) {
            // v3.0 uses save path for ID (from what I can tell)
            $persistentId = 'memc-session:' . $savePath;

            // v2.0 uses "PERSISTENT=foo servers", so parse that.
            if (strpos($savePath, 'PERSISTENT=') === 0) {
                $end = strpos($savePath, ' ');
                if ($end === false) {
                    throw new InvalidArgumentException('Unable to parse session save_path');
                }

                $persistentId = substr($savePath, 11, $end - 11);
            }

            return $persistentId;
        }

        // Try based on specified value in options.
        if ($options->has('persistent_id')) {
            return $options['persistent_id'];
        }

        // Determine automatically.
        $hashParts = [];

        foreach ($connections as $conn) {
            $hashParts[] = sprintf('%s:%s:%s', $conn['host'], $conn['port'], $conn['weight']);
        }
        foreach ($options as $key => $value) {
            $hashParts[] = $key . ':' . $value;
        }

        $hash = hash('sha256', implode(',', $hashParts));

        return $hash;
    }
protected function parsePersistentId(array $connections, OptionsBag $options, OptionsBag $sessionOptions)
    {
        // Try based on save_path.
        $savePath = $sessionOptions['save_path'];
        $savePath = trim($savePath); // Just in case.
        if ($savePath) {
            // v3.0 uses save path for ID (from what I can tell)
            $persistentId = 'memc-session:' . $savePath;

            // v2.0 uses "PERSISTENT=foo servers", so parse that.
            if (strpos($savePath, 'PERSISTENT=') === 0) {
                $end = strpos($savePath, ' ');
                if ($end === false) {
                    throw new InvalidArgumentException('Unable to parse session save_path');
                }

                $persistentId = substr($savePath, 11, $end - 11);
            }

            return $persistentId;
        }

        // Try based on specified value in options.
        if ($options->has('persistent_id')) {
            return $options['persistent_id'];
        }

        // Determine automatically.
        $hashParts = [];

        foreach ($connections as $conn) {
            $hashParts[] = sprintf('%s:%s:%s', $conn['host'], $conn['port'], $conn['weight']);
        }
        foreach ($options as $key => $value) {
            $hashParts[] = $key . ':' . $value;
        }

        $hash = hash('sha256', implode(',', $hashParts));

        return $hash;
    }
protected function parsePersistentId ( array $ connections , OptionsBag $ options , OptionsBag $ sessionOptions ) { // Try based on save_path. $ savePath = $ sessionOptions [ 'save_path' ] ; $ savePath = trim ( $ savePath ) ; // Just in case. if ( $ savePath ) { // v3.0 uses save path for ID (from what I can tell) $ persistentId = 'memc-session:' . $ savePath ; // v2.0 uses "PERSISTENT=foo servers", so parse that. if ( strpos ( $ savePath , 'PERSISTENT=' ) === 0 ) { $ end = strpos ( $ savePath , ' ' ) ; if ( $ end === false ) { throw new InvalidArgumentException ( 'Unable to parse session save_path' ) ; } $ persistentId = substr ( $ savePath , 11 , $ end - 11 ) ; } return $ persistentId ; } // Try based on specified value in options. if ( $ options -> has ( 'persistent_id' ) ) { return $ options [ 'persistent_id' ] ; } // Determine automatically. $ hashParts = [ ] ; foreach ( $ connections as $ conn ) { $ hashParts [ ] = sprintf ( '%s:%s:%s' , $ conn [ 'host' ] , $ conn [ 'port' ] , $ conn [ 'weight' ] ) ; } foreach ( $ options as $ key => $ value ) { $ hashParts [ ] = $ key . ':' . $ value ; } $ hash = hash ( 'sha256' , implode ( ',' , $ hashParts ) ) ; return $ hash ; }
Parse the Persistent ID from save_path and sets it on options.

1. Given in save_path "PERSISTENT=foo"
2. Given in options via "persistent_id"
3. Determined automatically based on current connections and options.

@param OptionsBag[] $connections
@param OptionsBag   $options
@param OptionsBag   $sessionOptions

@return string
Parse the Persistent ID from save_path and sets it on options .