Samo Čretnik
Samo Čretnik

Reputation: 31

Libmemcached.php on line 395

Error from /var/log/system.log when memcached is enabled in local.xml:

2016-03-06T00:37:16+00:00 ERR (3): Warning: Division by zero in /public_html/demo/lib/Zend/Cache/Backend/Libmemcached.php on line 395

Site is on shared hosting with cloudlinux. Memcached part from local.xml looks like this:

<cache>
    <backend>memcached</backend>
    <slow_backend>database</slow_backend>
    <slow_backend_store_data>0</slow_backend_store_data>
    <auto_refresh_fast_cache>0</auto_refresh_fast_cache>
      <memcached>
        <servers>
            <server>
                <host><![CDATA[127.0.0.1]]></host>
                <port><![CDATA[11211]]></port>
                <persistent><![CDATA[1]]></persistent>
            </server>
        </servers>
        <compression><![CDATA[0]]></compression>
        <cache_dir><![CDATA[]]></cache_dir>
        <hashed_directory_level><![CDATA[]]></hashed_directory_level>
        <hashed_directory_umask><![CDATA[]]></hashed_directory_umask>
        <file_name_prefix><![CDATA[]]></file_name_prefix>
    </memcached>
</cache>

Any ideas, how to fix this? Do I need any fix in local.xml in order to avoid this error? I was checking CPU usage in cpanel and it's almost 88/100 all the time, if I disable memcached from local.xml, CPU usage drops to normal 22/100.

if ($memSize === null || $memUsed === null) {
    $mem = $this->_memcache->getstats();
    if (isset($mem['limit_maxbytes']) && $mem['limit_maxbytes'] > 0) {
        return ((int) (100 * ($mem['bytes'] / $mem['limit_maxbytes'])));
    } else {
        return 100;
    }

Line 395 is: } else {

Upvotes: 0

Views: 577

Answers (1)

user1536205
user1536205

Reputation: 1

Lowering the error reporting level by adding/modifying the following function call in index.php should suppress the warning message, but of course at some point of time you may want it to be turned back on and this annoying problem will come back...

error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING);

Hope this is helpful.

Upvotes: 0

Related Questions