Issues

ZF-4614: Zend_Cache_Backend_Memcached infinite lifetime

Issue Type: Bug Created: 2008-10-16T07:12:15.000+0000 Last Updated: 2008-11-13T14:09:53.000+0000 Status: Resolved Fix version(s): - 1.7.0 (17/Nov/08)

Reporter: Bob Gaudaen (bgaudaen) Assignee: Fabien MARTY (fab) Tags: - Zend_Cache

Related issues: Attachments:

Description

Zend_Cache_Backend_Memcached doesn't transform 'null' lifetime to '0' to have an infinite lifetime.

Find hereby a patch proposal:

<pre class="highlight">
--- Zend/Cache/Backend/Memcached.php    (revision 764)
+++ Zend/Cache/Backend/Memcached.php    (working copy)
@@ -167,6 +167,13 @@
     public function save($data, $id, $tags = array(), $specificLifetime = false)
     {
         $lifetime = $this->getLifetime($specificLifetime);
+        if ($lifetime > 2592000) {
+            # ZF-3490 : For the memcached backend, there is a lifetime limit of 30 days (2592000 seconds)
+            $this->_log('memcached backend has a limit of 30 days (2592000 seconds) for the lifetime');
+        } elseif (is_null($lifetime)) {
+           // For the memcached backend, we need a lifetime of 0 for infinite lifetime instead of null
+           $lifetime = 0;
+        }
         if ($this->_options['compression']) {
             $flag = MEMCACHE_COMPRESSED;
         } else {
@@ -230,21 +237,4 @@
     {
         return false;
     }
-
-    /**
-     * Set the frontend directives
-     *
-     * @param  array $directives Assoc of directives
-     * @throws Zend_Cache_Exception
-     * @return void
-     */
-    public function setDirectives($directives)
-    {
-        parent::setDirectives($directives);
-        $lifetime = $this->getLifetime(false);
-        if ($lifetime > 2592000) {
-            # ZF-3490 : For the memcached backend, there is a lifetime limit of 30 days (2592000 seconds)
-            $this->_log('memcached backend has a limit of 30 days (2592000 seconds) for the lifetime');
-        }
-    }
 }

Comments

Posted by Fabien MARTY (fab) on 2008-10-27T12:00:05.000+0000

see ZF-3490 : For the memcached backend, there is a lifetime limit of 30 days (2592000 seconds)

so we should transform null to 2592000 (instead of 0), shouldn't we ?

Posted by Mauricio Cuenca (mauricio) on 2008-11-06T03:09:06.000+0000

I think you should stay with null to 0. This is value expected by PHP's Memcache module.

Maybe the people from Memcached ships a new version supporting a longer lifetime, this way, passing 0 will guarantee the max allowed lifetime without changing the code.

Posted by Fabien MARTY (fab) on 2008-11-13T00:13:02.000+0000

commited in svn trunk

Posted by Wil Sinclair (wil) on 2008-11-13T14:09:51.000+0000

Changing issues in preparation for the 1.7.0 release.

Have you found an issue?

See the Overview section for more details.

Copyright

© 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.

Contacts