I want to use memcache into my application. I have enabled php_memcache.dll in php.ini file and normal memcache is working fine in simple PHP.
$memcache = new Memcache;
$memcache->connect('localhost', 11211);
$test = $memcache->get("A");
if(empty($test)){
echo "setting cache";
$memcache->set("A","Cache contents",MEMCACHE_COMPRESSED,50);
}
echo $test;
But I don't know how to create object for Memcache in Zend Framework 2 for normal Memcache, when I am trying to shows error as:
Fatal error: Class 'Application\Controller\Memcache' not found
Please help me to solve my problem.
It seems you are trying to initialize Memcache
object from your controller, which is in Application\Controller
namespace. In this case, it looks for Memcache
in the same namespace. You need to refer it from global namespace as:
$memcache = new \Memcache;