protected function _pop3Cache(
        $type, $index = self::MBOX_CACHE, $data = null
    )
    {
        if (isset($this->_temp['pop3cache'][$index][$type])) {
            if ($type == 'msg') {
                rewind($this->_temp['pop3cache'][$index][$type]);
            }
            return $this->_temp['pop3cache'][$index][$type];
        }

        switch ($type) {
        case 'hdr':
        case 'top':
            $data = null;
            if (($type == 'top') || $this->_capability('TOP')) {
                try {
                    $res = $this->_sendLine('TOP ' . $index . ' 0', array(
                        'multiline' => 'stream'
                    ));
                    rewind($res['data']);
                    $data = stream_get_contents($res['data']);
                    fclose($res['data']);
                } catch (Horde_Imap_Client_Exception $e) {
                    $this->_temp['no_top'] = true;
                    if ($type == 'top') {
                        return null;
                    }
                }
            }

            if (is_null($data)) {
                $data = Horde_Mime_Part::getRawPartText(stream_get_contents($this->_pop3Cache('msg', $index)), 'header', 0);
            }
            break;

        case 'hdrob':
            $data = Horde_Mime_Headers::parseHeaders($this->_pop3Cache('hdr', $index));
            break;

        case 'msg':
            $res = $this->_sendLine('RETR ' . $index, array(
                'multiline' => 'stream'
            ));
            $data = $res['data'];
            rewind($data);
            break;

        case 'size':
        case 'uidl':
            $data = array();
            try {
                $res = $this->_sendLine(($type == 'size') ? 'LIST' : 'UIDL', array(
                    'multiline' => 'array'
                ));
                foreach ($res['data'] as $val) {
                    $resp_data = explode(' ', $val, 2);
                    $data[$resp_data[0]] = $resp_data[1];
                }
            } catch (Horde_Imap_Client_Exception $e) {
                if ($type == 'uidl') {
                    $this->_temp['no_uidl'] = true;
                }
            }
            break;

        case 'stat':
            $resp = $this->_sendLine('STAT');
            $resp_data = explode(' ', $resp['resp'], 2);
            $data = array('msgs' => $resp_data[0], 'size' => $resp_data[1]);
            break;
        }

        $this->_temp['pop3cache'][$index][$type] = $data;

        return $data;
    }