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 />
------解决思路----------------------
你查下数据不就行了

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Chinese version
Chinese version, very easy to use
