ZF-8856: Zend_Cache_Backend_Memcached bad performance on adding setting keys

Issue Type: Performance Improvement Created: 2010-01-18T04:33:31.000+0000 Last Updated: 2010-01-24T16:18:06.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Are Pedersen (are) Assignee: Marc Bennewitz (private) (mabe) Tags: - Zend_Cache

Related issues: - ZF-5702



In the Zend_Cache_Backend_Memcached->save method it tries memcache->add and if it fails does a memcache->set. The comment just above this code says that set() seems slower.

My tests indicate that add() and set() is almost identical in speed.

Also, if done in this way we assume that the cache-keys doesn't already exist most of the time (that add() doesn't fail). If add() fails, the saving of a cache will take double time.

I propose to just call memcache->set(), and not do add() at all. This will give consistent speed on saving the cache.


Posted by Marc Bennewitz (private) (mabe) on 2010-01-21T12:40:23.000+0000

Yes, on replacing items all memcache requests are send twice. But in inserting new one the requests are send once but memcache isn't really faster because memcache have to check if the item exits anyway.

Therefor a simple set is enough.

I'm planing to integrate some new functionality (like add, replace, multiple interface etc.) but there few toto's: (…)

Posted by Marc Bennewitz (private) (mabe) on 2010-01-22T11:24:18.000+0000

The add method was implemented by another issue:

save() performs a replace() when it's intending to do a set(), and replace() apparently doesn't work on older (<= 1.2.3) versions of memcached.

But I can't find any verifications for this testimony:

set() is rather slow in memcached

Posted by Marc Bennewitz (private) (mabe) on 2010-01-22T11:36:49.000+0000

If replace doesn't work with memcached <= 1.2.3, I don't now why replace() is used within touch() ?!??! Can't find this replace() bug within memcached changelog. I will try to test out it within the next days.

Posted by Marc Bennewitz (private) (mabe) on 2010-01-24T16:18:05.000+0000

I tested the replace command with memcached 1.2.3 but it works fine.

Fixed in r20590 (trunk) & r20591 (1.10 branch)

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.