{"id":1987,"date":"2022-08-30T15:21:06","date_gmt":"2022-08-30T15:21:06","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/08\/php-memcache-is-installed-and-working-but-sporadic-class-memcache-not-found-error-occurs-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:21:06","modified_gmt":"2022-08-30T15:21:06","slug":"php-memcache-is-installed-and-working-but-sporadic-class-memcache-not-found-error-occurs-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/php-memcache-is-installed-and-working-but-sporadic-class-memcache-not-found-error-occurs-collection-of-common-programming-errors\/","title":{"rendered":"PHP memcache is installed and working, but sporadic Class &#39;Memcache&#39; not found error occurs-Collection of common programming errors"},"content":{"rendered":"<p>I am using the following:<\/p>\n<ul>\n<li>lighttpd\/1.4.31 (ssl)<\/li>\n<li>lighttpd-fastcgi<\/li>\n<li>php 5.3.16<\/li>\n<li>php-pecl-memcache<\/li>\n<li>CentOS<\/li>\n<\/ul>\n<p>I have memcached service running. phpinfo() reports that memcache extension is installed. My application is using memcache extension successfully, servicing thousands of queries. This is how I am initialising memcache:<\/p>\n<pre><code>$memcache = new Memcache;\n$memcache-&gt;connect('localhost', 11211);\n<\/code><\/pre>\n<p>However, after reading error log, I notice that right after I restarted lighttpd, and then once in a while log gets the following error:<\/p>\n<blockquote>\n<p>2012-09-01 10:56:02: (mod_fastcgi.c.2676) FastCGI-stderr: PHP Fatal error: Class &#8216;Memcache&#8217; not found in \/var\/www\/script.php on line 6<\/p>\n<\/blockquote>\n<p>Line 6 being the following &#8220;$memcache = new Memcache;&#8221;.<\/p>\n<p>Again, my application generally works, and thousands of requests using memcache are going OK, otherwise my application would not service a single request. It is only sometimes PHP is unable to find memcache class, but not everytime, which is what baffling me.<\/p>\n<p>Any ideas what could be causing this issue? I have reinstalled PHP, checked my code thoroughly.<\/p>\n<p>Update:<\/p>\n<p>Seems like other default PHP classes are failing as well randomly during the run time:<\/p>\n<blockquote>\n<p>2012-09-01 12:19:48: (mod_fastcgi.c.2676) FastCGI-stderr: PHP Fatal error: Call to undefined function json_encode()<\/p>\n<\/blockquote>\n<p id=\"rop\"><small>Originally posted 2013-12-08 05:36:06. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I am using the following: lighttpd\/1.4.31 (ssl) lighttpd-fastcgi php 5.3.16 php-pecl-memcache CentOS I have memcached service running. phpinfo() reports that memcache extension is installed. My application is using memcache extension successfully, servicing thousands of queries. This is how I am initialising memcache: $memcache = new Memcache; $memcache-&gt;connect(&#8216;localhost&#8217;, 11211); However, after reading error log, I notice [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,1],"tags":[],"class_list":["post-1987","post","type-post","status-publish","format-standard","hentry","category-php-memcached","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1987","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1987"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1987\/revisions"}],"predecessor-version":[{"id":8992,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1987\/revisions\/8992"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1987"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}