Zend Framework

Add 'memcached' Support to Zend_Cache_Backend

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.11.1
  • Component/s: Zend_Cache
  • Labels:
    None

Description

Zend_Cache_Backend does not support Memcached from the 'memcached' extension side.
This has been brought up several times, however, I have one called "Memcached2" that provides the memcached extension availability. This was somewhat forked from the current Zend_Cache_Backend_Memcached, with some slight modifications to support what Memcached does.

This has the same tests that the current Zend_Cache_Backend_Memcached does and passes all of them.

Attached is the patch file.

Activity

Hide
Mike Willbanks added a comment -

Patch for Memcached2.

Changes:
M tests/TestConfiguration.php.dist
M tests/Zend/Cache/SkipTests.php
M tests/Zend/Cache/AllTests.php
A tests/Zend/Cache/Memcached2BackendTest.php
A library/Zend/Cache/Backend/Memcached2.php

Show
Mike Willbanks added a comment - Patch for Memcached2. Changes: M tests/TestConfiguration.php.dist M tests/Zend/Cache/SkipTests.php M tests/Zend/Cache/AllTests.php A tests/Zend/Cache/Memcached2BackendTest.php A library/Zend/Cache/Backend/Memcached2.php
Hide
Mike Willbanks added a comment -

Please apply patch or what changes you need

Show
Mike Willbanks added a comment - Please apply patch or what changes you need
Hide
Marc Bennewitz (private) added a comment -

Thanks for your patch but this is a new backend and would need a proposal.
Additionally 1.11 beta is released and therefore no new features will get in.

The current refactoring of the cache component for zf2 contains an adapter for ext/memcached
-> http://framework.zend.com/wiki/display/ZFPROP/Zend+Cache+2.0+-+Marc+Bennewitz

Show
Marc Bennewitz (private) added a comment - Thanks for your patch but this is a new backend and would need a proposal. Additionally 1.11 beta is released and therefore no new features will get in. The current refactoring of the cache component for zf2 contains an adapter for ext/memcached -> http://framework.zend.com/wiki/display/ZFPROP/Zend+Cache+2.0+-+Marc+Bennewitz
Hide
Matthew Weier O'Phinney added a comment -

Marc – adapters can come in as feature improvements in the tracker, so long as they are straight-forward. (This differs from the policy for filters, as they operate standalone.) Also, while we are technically in beta, our concept of beta is fairly fluid; we allow minor feature additions so long as they create new functionality and do not change existing functionality, and are trivial in scope.

How different is the attached adapter from what you've done for ZF2? If the differences are minimal or non-existent, I can see use cases for having this in the 1.X series.

Show
Matthew Weier O'Phinney added a comment - Marc – adapters can come in as feature improvements in the tracker, so long as they are straight-forward. (This differs from the policy for filters, as they operate standalone.) Also, while we are technically in beta, our concept of beta is fairly fluid; we allow minor feature additions so long as they create new functionality and do not change existing functionality, and are trivial in scope. How different is the attached adapter from what you've done for ZF2? If the differences are minimal or non-existent, I can see use cases for having this in the 1.X series.
Hide
Marc Bennewitz (private) added a comment -

metthew - this differs from last upgrade to 1.10 there was an alpha before
OK than I'll review and commit it this weekend but the name "Memcached2" seems improper to me. The other backend "Memcached" based on ext/memcache is blocking the name but ext/memcached is based on libmemcached and I would like to name it "Libmemcached" until zf2 - that do you think ?.

ps: Zend Cache 2 has a complete different structure and comparing isn't simply possible.

Show
Marc Bennewitz (private) added a comment - metthew - this differs from last upgrade to 1.10 there was an alpha before OK than I'll review and commit it this weekend but the name "Memcached2" seems improper to me. The other backend "Memcached" based on ext/memcache is blocking the name but ext/memcached is based on libmemcached and I would like to name it "Libmemcached" until zf2 - that do you think ?. ps: Zend Cache 2 has a complete different structure and comparing isn't simply possible.
Hide
Mike Willbanks added a comment -

That name would likely be better
/me kicks current Memcached for being named evil.

Show
Mike Willbanks added a comment - That name would likely be better /me kicks current Memcached for being named evil.
Hide
Marc Bennewitz (private) added a comment -

Commited your patch in r23136 (trunk) with some changes:

  • renamed to Libmemcached
  • added logging on failed calls of set
  • removed memcached option constants
  • changed client config to allow constant values of Memcached::OPT_*
    and override default Memcached configuration on constructor

Please take a look into it - Thanks

Show
Marc Bennewitz (private) added a comment - Commited your patch in r23136 (trunk) with some changes:
  • renamed to Libmemcached
  • added logging on failed calls of set
  • removed memcached option constants
  • changed client config to allow constant values of Memcached::OPT_* and override default Memcached configuration on constructor
Please take a look into it - Thanks
Hide
Kazusuke Sasezaki added a comment -

r23136 Libmemcached.php Copyright is "2005-2008"

Show
Kazusuke Sasezaki added a comment - r23136 Libmemcached.php Copyright is "2005-2008"
Hide
Marc Bennewitz (private) added a comment -

changed - thanks

Show
Marc Bennewitz (private) added a comment - changed - thanks
Hide
Mike Willbanks added a comment -

r23136 - Libmemcached.php

Constructor:
If the client option is not found in the else condition during the constructor, it should either raise an exception or log a message. This is really while it is looking for the client constant option. Also when setting the client option it will return true or false, we could also add logging to that.

Not really absolutely needed but could be added to give the developer a better idea if something is going wrong.

Really like the way you implemented the client options.

Show
Mike Willbanks added a comment - r23136 - Libmemcached.php Constructor: If the client option is not found in the else condition during the constructor, it should either raise an exception or log a message. This is really while it is looking for the client constant option. Also when setting the client option it will return true or false, we could also add logging to that. Not really absolutely needed but could be added to give the developer a better idea if something is going wrong. Really like the way you implemented the client options.
Hide
Marc Bennewitz (private) added a comment -

adding logging

Additionally if I remove the sleep(1) on tests tearDown() all tests passed on my test machine.
-> Is that really needed ?

Show
Marc Bennewitz (private) added a comment - adding logging Additionally if I remove the sleep(1) on tests tearDown() all tests passed on my test machine. -> Is that really needed ?
Hide
Mike Willbanks added a comment -

I don't really think it is needed. With the tests I started off with the same tests that were contained in the current memcached class and started to extend them. Since that one had a sleep(1) i kept it in since I didn't know if there was a CI server that would have required it.

Show
Mike Willbanks added a comment - I don't really think it is needed. With the tests I started off with the same tests that were contained in the current memcached class and started to extend them. Since that one had a sleep(1) i kept it in since I didn't know if there was a CI server that would have required it.
Hide
Marc Bennewitz (private) added a comment - - edited

merged to 1.11 branch in r23154

  • I leave the sleep(1) on tearDown()
Show
Marc Bennewitz (private) added a comment - - edited merged to 1.11 branch in r23154
  • I leave the sleep(1) on tearDown()

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: