2

I used the following combination ::

OS                  -> CentOS
php                 -> 5.4
Memcached Server    -> 1.4
Memcached           -> 2.1     [ client library for php ]
libmemcached        -> 1.0.16

and following code

<?php
class mem{
        public $mem = null;
        public static $x = 0;

        public function __construct()
        {
                $this->mem = new Memcached();
                $this->mem->addServer("localhost",11211);
                $op = $this->mem->add("key_".self::$x, "test");
        }
        public function __destruct()
        {
                $op = $this->mem->delete("key_".self::$x);
                $this->mem = null;
                self::$x++;
        }
}
for($i=0;$i<100000;$i++){
        $v = new mem();
}
?>

When this php script completes, I found that 5-10 keys were not deleted.

Now when I changed

libmemcached to 0.48
memcached    to 2.0

each key got deleted

I repeated these steps and found that this problem can be easily reproduced.

Now I had these two setups on different machines and a common memcache server. Again several keys from newer setup were not deleted. Moreover by increasing the concurrency of script, number of keys increased non-linearly.

I'm not able to understand what's wrong with this. Is it a bug?

Please help!

Tarun Chabarwal
  • 332
  • 4
  • 15

0 Answers0