Memcache for a live server eg http://www.xyz.com, what must be the connect() function below…? I inserting domain but does not work getting: Warning: Memcache::connect(): Can’t connect to xyz.com:11211, Connection refused (111) in /var/sites/b/xyz.com/public_html/xyz.php on line 13 Could not connect well?
<?php
$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211) or die ("Could not connect");
I make this observation: // why this???
echomc(); // this give error … if commented and uncomment next line Not error
//echo memcache_get($memcache_obj, ‘var_key’);
Warning: memcache_get() expects parameter 1 to be MemcachePool, null given in /var/sites/b/xyz.com/public_html/xyz.php on line 45
/* procedural API */
/* connect to memcached server */
$memcache_obj = memcache_connect('x.y.z.f', 11211);
/*
set value of item with key 'var_key'
using 0 as flag value, compression is not used
expire time is 30 seconds
*/
memcache_set($memcache_obj, 'var_key', 'some variable', 0, 30);
function echomc() {
echo memcache_get($memcache_obj, 'var_key');
}
echomc(); // this give error ... if commented and uncomment next line Not error
//echo memcache_get($memcache_obj, 'var_key');