6.0.0-beta1
7/6/25

[#12735] Xcache not expiring on get() if prefix is set
Summary Xcache not expiring on get() if prefix is set
Queue Horde Framework Packages
Queue Version Git master
Type Bug
State Resolved
Priority 1. Low
Owners slusarz (at) horde (dot) org
Requester wbreyha (at) gmx (dot) net
Created 10/04/2013 (4293 days ago)
Due
Updated 10/07/2013 (4290 days ago)
Assigned
Resolved 10/07/2013 (4290 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
10/07/2013 04:55:48 AM Michael Slusarz Comment #4
Assigned to Michael Slusarz
State ⇒ Resolved
Priority ⇒ 1. Low
Reply to this comment
Horde_Cache 2.3.0.
10/07/2013 04:55:26 AM Git Commit Comment #3 Reply to this comment
Changes have been made in Git (master):

commit 923c200e1165144f9d1bb4a1e39073bab4181dd8
Author: Michael M Slusarz <slusarz@horde.org>
Date:   Sun Oct 6 22:53:29 2013 -0600

     [mms] Fix key expiration for APC, Eaccelerator, and Xcache (Bug #12735).

  framework/Cache/lib/Horde/Cache/Storage/Apc.php    |    1 -
  .../Cache/lib/Horde/Cache/Storage/Eaccelerator.php |    1 -
  framework/Cache/lib/Horde/Cache/Storage/Xcache.php |    3 +--
  framework/Cache/package.xml                        |    2 ++
  4 files changed, 3 insertions(+), 4 deletions(-)

http://git.horde.org/horde-git/-/commit/923c200e1165144f9d1bb4a1e39073bab4181dd8
10/04/2013 11:59:27 PM wbreyha (at) gmx (dot) net Comment #2 Reply to this comment
I reconsidered my patch...

_setExpire is protected and used only in the Xcache Module for get() 
and exists(). Both add the prefix before calling _setExpire.

Removing the second addition of the prefix in _setExpire() seems more 
reasonable.

--------
--- Xcache.php.orig        2013-10-05 01:44:50.000000000 +0200
+++ Xcache.php        2013-10-05 01:55:58.000000000 +0200
@@ -97,7 +97,6 @@
              // don't expire
              return;
          }
-        $key = $this->_params['prefix'] . $key;
          $expire = xcache_get($key . '_expire');

          // set prune period
--------
10/04/2013 11:47:53 PM wbreyha (at) gmx (dot) net Comment #1
Priority ⇒ 3. High
Patch ⇒ No
Milestone ⇒
Queue ⇒ Horde Framework Packages
Summary ⇒ Xcache not expiring on get() if prefix is set
Type ⇒ Bug
State ⇒ Unconfirmed
Reply to this comment
If eg. kronolith freebusy fb.php uses
$fb = $cache->get($key, 360);
in case of Xcache get() adds the prefix to $key and calls 
_setExpire(). But there the prefix is added again.

I think this will work as expected and similar to other caching modules
--------------
--- Xcache.php.orig        2013-10-05 01:44:50.000000000 +0200
+++ Xcache.php        2013-10-05 01:45:58.000000000 +0200
@@ -40,8 +40,10 @@
       */
      public function get($key, $lifetime = 0)
      {
-        $key = $this->_params['prefix'] . $key;
+        /* prefix is added in _setExpire, too */
          $this->_setExpire($key, $lifetime);
+        /* add it after calling _setExpire */
+        $key = $this->_params['prefix'] . $key;
          $result = xcache_get($key);

          return empty($result)
---------

Saved Queries