php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58828 Delete items not releavent with multi servers
Submitted: 2009-08-25 04:50 UTC Modified: 2009-08-27 03:04 UTC
From: wilfried dot loche at fr dot adp dot com Assigned:
Status: Not a bug Package: memcache (PECL)
PHP Version: 5.2.9 OS: Linux (SUSE10 SP2)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: wilfried dot loche at fr dot adp dot com
New email:
PHP Version: OS:

 

 [2009-08-25 04:50 UTC] wilfried dot loche at fr dot adp dot com
Description:
------------
Hi,

I use Memcached server via Zend_Cache component. I use a load balanced architecture with 2 web servers (apache).

When I want to delete an item, I expect the delete() method would perform the operation on both servers I put. But it is not the case.

If it makes sense on getting items, to my mind, deletes and updates should be applied on the server pools... no?

Many thx for this great interface,
Wilfried

Reproduce code:
---------------
function getMemcache($port)
{
    $memcache = new Memcache;
    $memcache->addServer('localhost', $port) or die ('Could not connect #' . $port);
    return $memcache;
}

//--- SET !
$memcache = getMemcache(11214);
echo 'add(#11214): '; var_dump($memcache->add('KEY', 'data#11214'));
$memcache = getMemcache(11213);
echo 'add(#11213): '; var_dump($memcache->add('KEY', 'data#11213'));

//--- GET !
$memcache = getMemcache(11214);
echo 'get(#11214): '; var_dump($memcache->get('KEY'));
$memcache = getMemcache(11213);
echo 'get(#11213): '; var_dump($memcache->get('KEY'));

//--- DELETE ALL (try to...)
$memcache = new Memcache;
$memcache->addServer('localhost', 11214) or die ('Could not connect #' . $port);
$memcache->addServer('localhost', 11213) or die ('Could not connect #' . $port);
echo 'delete(#ALL): '; var_dump($memcache->delete('KEY'));

//--- GET !
$memcache = getMemcache(11214);
echo 'get(#11214) => false?: '; var_dump($memcache->get('KEY'));
$memcache = getMemcache(11213);
echo 'get(#11213) => false?: '; var_dump($memcache->get('KEY'));



Expected result:
----------------
add(#11214): bool(true)
add(#11213): bool(true)
get(#11214): string(10) "data#11214"
get(#11213): string(10) "data#11213"
delete(#ALL): bool(true)
get(#11214) => false?: bool(false)
get(#11213) => false?: bool(false)


Actual result:
--------------
add(#11214): bool(true)
add(#11213): bool(true)
get(#11214): string(10) "data#11214"
get(#11213): string(10) "data#11213"
delete(#ALL): bool(true)
get(#11214) => false?: string(10) "data#11214"
get(#11213) => false?: bool(false)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-26 12:27 UTC] mikael at synd dot info
When you add multiple servers to a pool the key is actually only stored on one of them, as determined by the hash strategy. The pool is used for load balancing, not redundancy.

Although the memcache.redundancy setting might be of help, if you call ini_set('memcache.redundancy', '2') before you create your pool in the example you will get the result you expected.
 [2009-08-26 16:47 UTC] wilfried dot loche at fr dot adp dot com
Thx a lot for your quick answer.
Unfortunatly, this functionnality seems new since the 3.0.x beta branch.
Do you know when it is planned to be released as a stable version? (I use it on production servers).

By the way, this is not so clear for me. The number 2, it-is a constant or the number of servers data should be duplicated?

To explain what I need, I have on memcache daemon on each web server (currently only 2). I never update data on cache, only add and delete. To ensure all nodes are up to date, I have to uncache data on each nodes.

Thx again,
Wilfried
 [2009-08-27 03:04 UTC] wilfried dot loche at fr dot adp dot com
I guess the answer is in the Release notes Version3.0.0:
Key and session redundancy (values are written to N mirrors)

Remains the question of stability ;)
Thx,
Wilfried Loche
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 09:01:26 2024 UTC