public function get($key, $default = null)
    {
        if (isset($this->queryHits[$key])) {
            return $this->queryHits[$key];
        }

        if (isset($this->queryMisses[$key])) {
            return $default;
        }

        list($namespace, $dataKey) = $this->namespaceAndKey($key);

        $prefix = $this->firstKeySegments($dataKey, $this->prefixLength($namespace, $dataKey));
        $arrayKey = $this->arrayKey($dataKey, $prefix);

        foreach ($this->dataForPrefix($namespace, $prefix) as $data) {

            if (!is_array($data)) {
                $this->queryHits[$key] = $data;
                return $data;
            }

            $result = $arrayKey ? Helper::offsetGet($data, $arrayKey) : $data;

            if ($result === null) {
                continue;
            }

            $this->queryHits[$key] = $result;
            return $result;
        }

        $this->queryMisses[$key] = true;

        return $default;

    }
public function get($key, $default = null)
    {
        if (isset($this->queryHits[$key])) {
            return $this->queryHits[$key];
        }

        if (isset($this->queryMisses[$key])) {
            return $default;
        }

        list($namespace, $dataKey) = $this->namespaceAndKey($key);

        $prefix = $this->firstKeySegments($dataKey, $this->prefixLength($namespace, $dataKey));
        $arrayKey = $this->arrayKey($dataKey, $prefix);

        foreach ($this->dataForPrefix($namespace, $prefix) as $data) {

            if (!is_array($data)) {
                $this->queryHits[$key] = $data;
                return $data;
            }

            $result = $arrayKey ? Helper::offsetGet($data, $arrayKey) : $data;

            if ($result === null) {
                continue;
            }

            $this->queryHits[$key] = $result;
            return $result;
        }

        $this->queryMisses[$key] = true;

        return $default;

    }
public function get ( $ key , $ default = null ) { if ( isset ( $ this -> queryHits [ $ key ] ) ) { return $ this -> queryHits [ $ key ] ; } if ( isset ( $ this -> queryMisses [ $ key ] ) ) { return $ default ; } list ( $ namespace , $ dataKey ) = $ this -> namespaceAndKey ( $ key ) ; $ prefix = $ this -> firstKeySegments ( $ dataKey , $ this -> prefixLength ( $ namespace , $ dataKey ) ) ; $ arrayKey = $ this -> arrayKey ( $ dataKey , $ prefix ) ; foreach ( $ this -> dataForPrefix ( $ namespace , $ prefix ) as $ data ) { if ( ! is_array ( $ data ) ) { $ this -> queryHits [ $ key ] = $ data ; return $ data ; } $ result = $ arrayKey ? Helper :: offsetGet ( $ data , $ arrayKey ) : $ data ; if ( $ result === null ) { continue ; } $ this -> queryHits [ $ key ] = $ result ; return $ result ; } $ this -> queryMisses [ $ key ] = true ; return $ default ; }
Get a named object by its id.

@param mixed $key
@param mixed $default (optional)

@return mixed
Get a named object by its id .