protected function prefixLength($namespace, $key)
    {
        if (isset($this->prefixLengths[$namespace])) {
            return $this->prefixLengths[$namespace];
        }

        $firstSegment = $this->firstKeySegments($key);

        $this->failOnMissingNamespace($namespace);

        foreach ($this->addedData[$namespace] as $data) {

            try {

                // If no exception occurs this is the right length
                isset($data[$firstSegment]);

                $this->prefixLengths[$namespace] = 1;
                return $this->prefixLengths[$namespace];

            } catch (KeyLengthException $e) {
                $this->prefixLengths[$namespace] = $e->getMinSegments();
                return $this->prefixLengths[$namespace];
            }

        }

        return 1;

    }
protected function prefixLength($namespace, $key)
    {
        if (isset($this->prefixLengths[$namespace])) {
            return $this->prefixLengths[$namespace];
        }

        $firstSegment = $this->firstKeySegments($key);

        $this->failOnMissingNamespace($namespace);

        foreach ($this->addedData[$namespace] as $data) {

            try {

                // If no exception occurs this is the right length
                isset($data[$firstSegment]);

                $this->prefixLengths[$namespace] = 1;
                return $this->prefixLengths[$namespace];

            } catch (KeyLengthException $e) {
                $this->prefixLengths[$namespace] = $e->getMinSegments();
                return $this->prefixLengths[$namespace];
            }

        }

        return 1;

    }
protected function prefixLength ( $ namespace , $ key ) { if ( isset ( $ this -> prefixLengths [ $ namespace ] ) ) { return $ this -> prefixLengths [ $ namespace ] ; } $ firstSegment = $ this -> firstKeySegments ( $ key ) ; $ this -> failOnMissingNamespace ( $ namespace ) ; foreach ( $ this -> addedData [ $ namespace ] as $ data ) { try { // If no exception occurs this is the right length isset ( $ data [ $ firstSegment ] ) ; $ this -> prefixLengths [ $ namespace ] = 1 ; return $ this -> prefixLengths [ $ namespace ] ; } catch ( KeyLengthException $ e ) { $ this -> prefixLengths [ $ namespace ] = $ e -> getMinSegments ( ) ; return $ this -> prefixLengths [ $ namespace ] ; } } return 1 ; }
Determine the amount of segments that should be cached. Within a normal
array this is always 1. But some storages are using nested directories
and these needs a minimum key segments.
This is done once and perhaps expensive, depends on the storage.

@param string $namespace
@param string $key

@return int
Determine the amount of segments that should be cached . Within a normal array this is always 1 . But some storages are using nested directories and these needs a minimum key segments . This is done once and perhaps expensive depends on the storage .