Maison  >  Article  >  développement back-end  >  ecshop改了模板类使用memcached之后如何判断调用成功

ecshop改了模板类使用memcached之后如何判断调用成功

WBOY
WBOYoriginal
2016-06-13 12:11:141134parcourir

ecshop改了模板类使用memcached之后怎么判断调用成功?
问题就是这样,
function fetch
function is_cached
改了这两个函数部分
ecshop 自身是不报错了,但是现在就是不知道 ecshop 对缓存调用 成功不?请各位大大pp。help。

<br />/**<br />     * 处理模板文件<br />     *<br />     * @access  public<br />     * @param   string      $filename<br />     * @param   sting      $cache_id<br />     *<br />     * @return  sring<br />     */<br />    function fetch($filename, $cache_id = '')<br />    {<br />        if (!$this->_seterror)<br />        {<br />            error_reporting(E_ALL ^ E_NOTICE);<br />        }<br />        $this->_seterror++;<br /><br />        if (strncmp($filename,'str:', 4) == 0)<br />        {<br />            $out = $this->_eval($this->fetch_str(substr($filename, 4)));<br />        }<br />        else<br />        {<br />            if ($this->_checkfile)<br />            {<br />                if (!file_exists($filename))<br />                {<br />                    $filename = $this->template_dir . '/' . $filename;<br />                }<br />            }<br />            else<br />            {<br />                $filename = $this->template_dir . '/' . $filename;<br />            }<br /><br />            if ($this->direct_output)<br />            {<br />                $this->_current_file = $filename;<br /><br />                $out = $this->_eval($this->fetch_str(file_get_contents($filename)));<br />            }<br />            else<br />            {<br />                if ($cache_id && $this->caching)<br />                {<br />                    $out = $this->template_out;<br />                }<br />                else<br />                {<br />                    if (!in_array($filename, $this->template))<br />                    {<br />                        $this->template[] = $filename;<br />                    }<br /><br />                    $out = $this->make_compiled($filename);<br /><br />                    if ($cache_id)<br />                    {<br />                        $cachename = basename($filename, strrchr($filename, '.')) . '_' . $cache_id;<br />                        $data = serialize(array('template' => $this->template, 'expires' => $this->_nowtime + $this->cache_lifetime, 'maketime' => $this->_nowtime));<br />                        $out = str_replace("\r", '', $out);<br />						<br />						$memcache = new Memcache;<br />						$memcache->connect("127.0.0.1", 11211);<br />						$CacheID = md5($filename.$cache_id.$cachename);<br /><br />                        while (strpos($out, "\n\n") !== false)<br />                        {<br />                            $out = str_replace("\n\n", "\n", $out);<br />                        }<br />						<br />						$memcache->set($CacheID , '<?php exit;?>' . $data . $out , 3600);<br />						<br />                        $this->template = array();<br />                    }<br />                }<br />            }<br />        }<br /><br />        $this->_seterror--;<br />        if (!$this->_seterror)<br />        {<br />            error_reporting($this->_errorlevel);<br />        }<br /><br />        return $out; // 返回html数据<br />    }<br />


<br />/**<br />     * 判断是否缓存<br />     *<br />     * @access  public<br />     * @param   string     $filename<br />     * @param   sting      $cache_id<br />     *<br />     * @return  bool<br />     */<br />    function is_cached($filename, $cache_id = '')<br />    {<br />        $cachename = basename($filename, strrchr($filename, '.')) . '_' . $cache_id;<br />		<br />		$memcache = new Memcache;<br />		$memcache->connect("127.0.0.1", 11211);<br />		$CacheID = md5($filename.$cache_id.$cachename);<br />		<br />        if ($this->caching == true && $this->direct_output == false)<br />        {<br />			if ($data = $memcache->get($CacheID))<br />            {<br />                $data = substr($data, 13);<br />                $pos  = strpos($data, '<');<br />                $paradata = substr($data, 0, $pos);<br />                $para     = @unserialize($paradata);<br />                if ($para === false || $this->_nowtime > $para['expires'])<br />                {<br />                    $this->caching = false;<br /><br />                    return false;<br />                }<br />                $this->_expires = $para['expires'];<br /><br />                $this->template_out = substr($data, $pos);<br /><br />                foreach ($para['template'] AS $val)<br />                {<br />                    $stat = @stat($val);<br />                    if ($para['maketime'] < $stat['mtime'])<br />                    {<br />                        $this->caching = false;<br /><br />                        return false;<br />                    }<br />                }<br />            }<br />            else<br />            {<br />                $this->caching = false;<br /><br />                return false;<br />            }<br /><br />            return true;<br />        }<br />        else<br />        {<br />            return false;<br />        }<br />    }<br />

------解决思路----------------------
你查下数据不就行了

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn