Solved

PHP and memcache -- getting started

Posted on 2014-12-10
17
94 Views
Last Modified: 2014-12-11
The PHP memcache example is not working for me.
http://php.net/manual/en/memcache.examples-overview.php

Fatal error: Class 'Memcache' not found

I suspect I need to require_once something.

I'm running PHP 5.2.4 and phpinfo() reports /etc/php5/apache2/conf.d/memcache.ini in the "additional .ini files parsed"

what am I failing to do?

Thanks!
0
Comment
Question by:Daniel Wilson
  • 10
  • 7
17 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40493092
What exactly are you trying to do
In php there is Memcache and Memcached - you are probably trying to reference the wrong one - but there could be a dozen different reasons for the error
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40493094
I am attempting to cache a result set from MySql.

But ... to get there, I am attempting to follow the example so I can do SOMETHING with memcache or memcached.
0
 
LVL 58

Expert Comment

by:Gary
ID: 40493097
Do a phpinfo() to be sure what you are using

Either memcache or memcached is not installed or they are not enabled in php.ini
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40493104
The line in "additional.ini files" is the only reference to memcache in phpinfo()

Build Date       Mar 11 2013 14:04:25
Server API       Apache 2.0 Handler
Virtual Directory Support       disabled
Configuration File (php.ini) Path       /etc/php5/apache2
Loaded Configuration File       /etc/php5/apache2/php.ini
Scan this dir for additional .ini files       /etc/php5/apache2/conf.d
additional .ini files parsed       /etc/php5/apache2/conf.d/APC.ini, /etc/php5/apache2/conf.d/gd.ini, /etc/php5/apache2/conf.d/memcache.ini, /etc/php5/apache2/conf.d/mysql.ini, /etc/php5/apache2/conf.d/mysqli.ini, /etc/php5/apache2/conf.d/pdo.ini, /etc/php5/apache2/conf.d/pdo_mysql.ini
PHP API       20041225
PHP Extension       20060613
Zend Extension       220060519
Debug Build       no
Thread Safety       disabled
Zend Memory Manager       enabled
IPv6 Support       enabled
Registered PHP Streams       zip, php, file, data, http, ftp, compress.bzip2, compress.zlib, https, ftps
Registered Stream Socket Transports       tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
Registered Stream Filters       string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, convert.iconv.*, bzip2.*, zlib.*
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40494066
So is there a connecting piece I must install?

Here's what my system reports at the command-line:
:~$ apt-cache search memcache
collectd - statistics collection and monitoring daemon
libcache-memcached-perl - Cache::Memcached - client library for memcached
libmemcache-dev - development headers for libmemcache C client API
libmemcache0 - C client API for memcached memory object caching system
php5-memcache - memcache extension module for PHP5
python-myghtyutils - Set of utility classes used by Myghty templating
memcached - A high-performance memory object caching system
0
 
LVL 58

Expert Comment

by:Gary
ID: 40494178
Do the phpinfo as above and check it is listed.
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40494230
Check what is listed?  What I've been trying to explain is that the only listing of anything memcache is in the snippet I posted in the "additional .ini files parsed " section.

Maybe I'm asking the wrong question.

What do I need to install so that I can use memcache or memcached from PHP?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40494250
phpinfo() will list all loaded libraries, if it's not listed there then it is not being loaded
There is no point going any further til we know that.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40494271
OK, it's not being loaded.

How do I get it to be loaded?
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40494310
Some pages recommend something with pecl.  But pecl is complaining about my PHP version.  I'm running PHP 5.2.4 on Ubuntu 8.  That may be part of the problem, but memcached has been around a LONG time ...
0
 
LVL 58

Expert Comment

by:Gary
ID: 40494315
Is that from running

apt-get install memcached
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40494335
yes, I did install memcached in that way.

So apt-get reports memcached is at the newest version.

However ... ps-A | grep memcach returns nothing.
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40494357
For what it's worth, the top comment here has an example that fails similarly for me:
http://php.net/manual/en/memcached.installation.php
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40494378
0
 
LVL 32

Author Closing Comment

by:Daniel Wilson
ID: 40494909
No doubt that's the right answer.  Not working on Ubuntu 8.04.4 LTS.  Server upgrade has been planned for a while ...
0
 
LVL 58

Expert Comment

by:Gary
ID: 40494925
Yeah, thats quite an old version and really should have been updated 2 years ago.
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40494931
True.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now