0

I'm using caching methods to my website, first :

apache configuration:

Listen 127.0.0.1:11211

php.ini configuration

extension=php_memcache.dll

I think everything is all right, But when trying this simple caching code :

$cache=new Memcache();
$cache->connect('127.0.0.1',11211);
$cache->set('mykey','Hello world');


echo $cache->get('mykey');

it sends me a message error :

Notice: Memcache::set() [memcache.set]: Server 127.0.0.1 (tcp 11211) failed with: Failed reading line from stream (0) on line 20 ,

Keep in mind that line 20 is $cache->set('mykey','hello world'), that means : it's already connected successfully through port 11211.

If this is a critical Bug in the Memcache library, then I would mention that I'm working on windows server , and I'd like to have "memcached" working on windows platform instead of memcache.

Thank you in advance.

SmootQ
  • 2,096
  • 7
  • 33
  • 58

1 Answers1

1

Try to using

$cache->add('mykey','Hello world');
Udit Trivedi
  • 246
  • 3
  • 14
  • I tried it , but it sends me the same error message . Notice: Memcache::add() [memcache.add]: Server 127.0.0.1 (tcp 11211) failed with: Failed reading line from stream (0) in C:\Program Files\EasyPHP-5.3.9\www\freespoke.com\mods.fun.com\views\account_settings.php on line 20 – SmootQ Jun 05 '12 at 11:42
  • $memcache_obj = memcache_connect('127.0.0.1', 11211); memcache_set($memcache_obj, 'mykey', 'Hello world', 0, 30); echo memcache_get($memcache_obj, 'mykey'); – Udit Trivedi Jun 05 '12 at 11:51
  • The same problem dude , Notice: memcache_set() [function.memcache-set]: Server 127.0.0.1 (tcp 11211) failed with: Failed reading line from stream (0) in C:\Program Files\EasyPHP-5.3.9\www\freespoke.com\mods.fun.com\views\account_settings.php on line 26 – SmootQ Jun 05 '12 at 11:54
  • Thank you anyway , +1... I think the problem is with Local Ip address , I will try it online. Look here : http://stackoverflow.com/questions/6045187/memcache-connects-but-doesnt-respond-to-any-command look at second answer – SmootQ Jun 05 '12 at 11:55