|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-06-08 08:07 UTC] vincent dot dupont at ausy dot be
Description:
------------
hi,
I'm testing memcached module and PECL extension.
I downloaded the PHP4.3.11 win32 php_memcache.dll.
I also downloaded the sources if this dll, where a script file example.php is provided.
This example works on my system with :
$memcache = memcache_connect('localhost', 11211) or die ("Could not connect");
however, the PHP documentation states :
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
this last script does not work. So it seems the PHP documentation of this memcache implementation is not up-to-date.
Do you know where I can find an up-to-date doc?
thank you
Vincent
Reproduce code:
---------------
<?php
//this code comes from the php_extensions sources.
//this works
$memcache = memcache_connect('localhost', 11211);
if ($memcache) {
echo("connected<br>");
$memcache->set("str_key", "String to store in memcached");
$memcache->set("num_key", 123);
$object = new StdClass;
$object->attribute = 'test';
$memcache->set("obj_key", $object);
$array = Array('assoc'=>123, 345, 567);
$memcache->set("arr_key", $array);
var_dump($memcache->get('str_key'));
echo("<br>");
var_dump($memcache->get('num_key'));
echo("<br>");
var_dump($memcache->get('obj_key'));
}
else {
echo "Connection to memcached failed";
}
?>
Actual result:
--------------
PHP error because the $memcache->connect() is no more implemented
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 08:00:01 2025 UTC |
$memcache = new Memcache; ($result = $memcache->connect('localhost', 11211)) or die ("Could not connect"); var_dump($result); Works fine for me and outputs "bool(true)" as expected, if you don't have a memcached listening on localhost:11211 then you get "Can't connect to localhost:11211 .." also as expected. Using memcache 2.0.4 on Linux 2.6 Are you sure the extension was loaded correctly, you can test this using "var_dump(extension_loaded('php_memcache.dll'));" which should output "bool(true)" If the problem persists could you attach the exact error message produced as well as the script you are using. //MikaelHi, I have exactly the same issue reported below, but when I test with: var_dump(extension_loaded('php_memcache.dll')); I get "bool(false)", so the extension is not loaded correctly. The question, why not? The memcache output from phpinfo lead me to believe all was well... Here's a summary of my set up: XP SP2, PHP 4.4.4, Apache 2.0.52, php_memcache.dll 4_4. phpinfo output has: Active persistent connections 0 Revision $Revision: 1.70 $ memcache.allow_failover 1 1 memcache.chunk_size 8192 8192 memcache.default_port 11211 11211 memcache.max_failover_attempts 20 20 Any ideas how I can proceed? I'd be very grateful for your help. Thanks in advance!I'm still having trouble, but now realize that: print_r(get_loaded_extensions()); lists 'memcache' as one of the loaded module, and therefore var_dump(extension_loaded('memcache')); returns 'bol(true)'.... Any ideas?