Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if memcache or memcached is installed for PHP?

How do I test if memcache or memcached (for PHP) is installed on my Apache webserver?

Memcache is a caching daemon designed especially for dynamic web applications to decrease database load by storing objects in memory.

like image 206
Robin Rodricks Avatar asked Sep 23 '09 02:09

Robin Rodricks


People also ask

What is the difference between memcache and Memcached?

They both have very basic difference while storing value. Memcache mostly considers every value as string whereas Memcached stores it value's original type. Thumbs up for your answer !


2 Answers

You can look at phpinfo() or check if any of the functions of memcache is available. Ultimately, check whether the Memcache class exists or not.

e.g.

if(class_exists('Memcache')){   // Memcache is enabled. } 
like image 199
mauris Avatar answered Oct 05 '22 12:10

mauris


why not use the extension_loaded() function?

like image 33
J.C. Inacio Avatar answered Oct 05 '22 14:10

J.C. Inacio