<?xml version="1.0" encoding="UTF-8"?> 
<?xml-stylesheet href="https://dev.horde.org/themes/horde//default/feed-rss.xsl" type="text/xsl"?> 
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
 <channel> 
  <title>Memcache storage is duplicating the key prefix</title> 
  <pubDate>Fri, 10 Apr 2026 13:09:16 +0000</pubDate> 
  <link>https://bugs.horde.org/ticket/10072</link> 
  <atom:link rel="self" type="application/rss+xml" title="Memcache storage is duplicating the key prefix" href="https://bugs.horde.org/ticket/10072/rss" /> 
  <description>Memcache storage is duplicating the key prefix</description> 
 
   
   
  <item> 
   <title>Attached patch.</title> 
   <description>Attached patch.</description> 
   <pubDate>Thu, 12 May 2011 11:49:29 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t64600</link> 
  </item> 
   
  <item> 
   <title>&gt; Attached patch.

no file attached.</title> 
   <description>&gt; Attached patch.

no file attached.</description> 
   <pubDate>Thu, 12 May 2011 12:22:20 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t64601</link> 
  </item> 
   
  <item> 
   <title>True story :-p</title> 
   <description>True story :-p</description> 
   <pubDate>Thu, 12 May 2011 13:48:42 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t64604</link> 
  </item> 
   
  <item> 
   <title>How is this duplicating the prefix?  The prefix is added onc</title> 
   <description>How is this duplicating the prefix?  The prefix is added once per method.  Where else would the prefix be added?</description> 
   <pubDate>Thu, 12 May 2011 20:48:20 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t64608</link> 
  </item> 
   
  <item> 
   <title>Because after setting that $key, the class will call $this-&gt;</title> 
   <description>Because after setting that $key, the class will call $this-&gt;_memcache-&gt;xxxmethod
In this class, $this-&gt;_memcache that is a Horde_Memcache object... 
This object always calls the function _key that prefixes the memcache prefix..thus, duplicating it.

</description> 
   <pubDate>Thu, 12 May 2011 21:39:23 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t64609</link> 
  </item> 
   
  <item> 
   <title>&gt; Because after setting that $key, the class will call 
&gt; $</title> 
   <description>&gt; Because after setting that $key, the class will call 
&gt; $this-&gt;_memcache-&gt;xxxmethod
&gt; In this class, $this-&gt;_memcache that is a Horde_Memcache object...
&gt; This object always calls the function _key that prefixes the memcache 
&gt; prefix..thus, duplicating it.

But how is a prefix configuration setting in the Horde_Cache-&gt;Memcache object relevant to what is going in Horde_Memcache?  Basic object oriented principle that classes are blind to the implementation details of other classes.

If this is happening in practice, the solution would be to ensure that the prefix given to the cache object is empty.  But removing prefixing in the cache object accomplishes nothing.</description> 
   <pubDate>Thu, 12 May 2011 22:14:30 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t64610</link> 
  </item> 
   
  <item> 
   <title>&gt; If this is happening in practice, the solution would be to</title> 
   <description>&gt; If this is happening in practice, the solution would be to ensure 
&gt; that the prefix given to the cache object is empty.  But removing 
&gt; prefixing in the cache object accomplishes nothing.

The default value for memcache caching prefix ($conf[&#039;cache&#039;][&#039;params&#039;][&#039;prefix&#039;]) is empty, so a duplicate prefix would be an issue with your local installation.</description> 
   <pubDate>Thu, 12 May 2011 22:20:39 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t64611</link> 
  </item> 
   
  <item> 
   <title>&gt; The default value for memcache caching prefix 
&gt; ($conf[&#039;</title> 
   <description>&gt; The default value for memcache caching prefix 
&gt; ($conf[&#039;cache&#039;][&#039;params&#039;][&#039;prefix&#039;]) is empty, so a duplicate prefix 
&gt; would be an issue with your local installation.

I have setted $conf[&#039;cache&#039;][&#039;params&#039;][&#039;prefix&#039;] because i have multiple horde instances (vhosts) in the same memcache...
If the value of $conf[&#039;cache&#039;][&#039;params&#039;][&#039;prefix&#039;] is something like &#039;ABC&#039; then i will have on my memcache duplicate keys like:
ABC_horde_perms_sql
ABC_ABC_horde_perms_sql
and for some others i even have triplicates!!! 
ABC_ABC_ABC_horde_perms_sql

Picking up a practical example:
Horde_Cache_Storage_Memcache method set(), adds the prefix to the key and then calls $this-&gt;_memcache-&gt;set().. and this method will also append the prefix to the $key, thus making it duplicate</description> 
   <pubDate>Fri, 13 May 2011 00:57:54 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t64612</link> 
  </item> 
   
  <item> 
   <title>&gt;&gt; The default value for memcache caching prefix
&gt;&gt; ($conf[</title> 
   <description>&gt;&gt; The default value for memcache caching prefix
&gt;&gt; ($conf[&#039;cache&#039;][&#039;params&#039;][&#039;prefix&#039;]) is empty, so a duplicate prefix
&gt;&gt; would be an issue with your local installation.
&gt;
&gt; I have setted $conf[&#039;cache&#039;][&#039;params&#039;][&#039;prefix&#039;] because i have 
&gt; multiple horde instances (vhosts) in the same memcache...
&gt; If the value of $conf[&#039;cache&#039;][&#039;params&#039;][&#039;prefix&#039;] is something like 
&gt; &#039;ABC&#039; then i will have on my memcache duplicate keys like:
&gt; ABC_horde_perms_sql
&gt; ABC_ABC_horde_perms_sql
&gt; and for some others i even have triplicates!!!
&gt; ABC_ABC_ABC_horde_perms_sql
&gt;
&gt; Picking up a practical example:
&gt; Horde_Cache_Storage_Memcache method set(), adds the prefix to the key 
&gt; and then calls $this-&gt;_memcache-&gt;set().. and this method will also 
&gt; append the prefix to the $key, thus making it duplicate

I still don&#039;t understand why this is an issue.  Please don&#039;t tell me you are looking at key names in your memcache (or any) backend.  Because that is completely irrelevant.

All that matters is that for a given key input to Cache::get() (or Cache::set()), a single, unique data value is associated with it.  If a key has 2, 3 (or 10) prefixes tacked on to the front, why does that matter?</description> 
   <pubDate>Fri, 13 May 2011 22:30:39 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t64653</link> 
  </item> 
   
  <item> 
   <title>&gt; I still don&#039;t understand why this is an issue.  Please don</title> 
   <description>&gt; I still don&#039;t understand why this is an issue.  Please don&#039;t tell me 
&gt; you are looking at key names in your memcache (or any) backend.  
&gt; Because that is completely irrelevant.

Yes, i was debugging memcache get() and set() methods.

&gt; All that matters is that for a given key input to Cache::get() (or 
&gt; Cache::set()), a single, unique data value is associated with it.  If 
&gt; a key has 2, 3 (or 10) prefixes tacked on to the front, why does that 
&gt; matter?

I think it matters, because without the patch after a single login i have (ex) 30 keys being created on cache. With the patch i only have like 12 or 13.. this is because without the patch every key is created twice in the database (one with one prefix the other with the prefix 2 times) and some are even created 3 times...

I don&#039;t say that memcache is not working correctly, im just saying that i think there&#039;s some problem with it. The way i see it having in the memcache something like:
PREFIX_number_of_session
PREFIX_PREFIX_number_of_session

doens&#039;t seem correct</description> 
   <pubDate>Sat, 14 May 2011 10:33:04 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t64663</link> 
  </item> 
   
  <item> 
   <title>&gt;&gt; I still don&#039;t understand why this is an issue.  Please do</title> 
   <description>&gt;&gt; I still don&#039;t understand why this is an issue.  Please don&#039;t tell me
&gt;&gt; you are looking at key names in your memcache (or any) backend.
&gt;&gt; Because that is completely irrelevant.
&gt;
&gt; Yes, i was debugging memcache get() and set() methods.
&gt;
&gt;&gt; All that matters is that for a given key input to Cache::get() (or
&gt;&gt; Cache::set()), a single, unique data value is associated with it.  If
&gt;&gt; a key has 2, 3 (or 10) prefixes tacked on to the front, why does that
&gt;&gt; matter?
&gt;
&gt; I think it matters, because without the patch after a single login i 
&gt; have (ex) 30 keys being created on cache. With the patch i only have 
&gt; like 12 or 13.. this is because without the patch every key is 
&gt; created twice in the database (one with one prefix the other with the 
&gt; prefix 2 times) and some are even created 3 times...
&gt;
&gt; I don&#039;t say that memcache is not working correctly, im just saying 
&gt; that i think there&#039;s some problem with it. The way i see it having in 
&gt; the memcache something like:
&gt; PREFIX_number_of_session
&gt; PREFIX_PREFIX_number_of_session

If this is happening then this *might* be an error.  You will have to track down where these alleged duplicate prefixes are being generated (Horde::debug() might be useful for this).

Note that just because the data value is the same, that does NOT mean that the key is being duplicated.  That is a dangerous assumption and is simply wrong.

FWIW, your patch doesn&#039;t fix this problem at all.  All you are doing is removing the prefix feature, which is not the correct solution.</description> 
   <pubDate>Mon, 16 May 2011 21:39:12 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t64713</link> 
  </item> 
   
  <item> 
   <title>&gt; I don&#039;t say that memcache is not working correctly, im jus</title> 
   <description>&gt; I don&#039;t say that memcache is not working correctly, im just saying 
&gt; that i think there&#039;s some problem with it. The way i see it having in 
&gt; the memcache something like:
&gt; PREFIX_number_of_session

This key would be created by something that *directly* calls Horde_Memcache.

&gt; PREFIX_PREFIX_number_of_session

This key would be created by something that calls Horde_Cache-&gt;memcache.

So these are two completely different calls.

If you are using something like memcache caching of session information, this is completely expected.  The session handler caches using direct queries to Horde_Memcache.  But that same data may be cached elsewhere via Horde_Cache.  So although the data happens to be the same, it is not a duplicate key - they are two independent keys that happen to have the same data.  As mentioned previously, this is an inevitable limitation of OO programming (and caching in general).</description> 
   <pubDate>Mon, 16 May 2011 21:52:13 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t64714</link> 
  </item> 
   
  <item> 
   <title>We are back to this issue, and discovered a problem on the e</title> 
   <description>We are back to this issue, and discovered a problem on the existing code (patch attached)

We agree that this is a conceptual problem, but it also doesn&#039;t make sense having the Horde_Cache_Storage_Memcache + Horde_Memcache duplicating the key prefix since one always calls the other.

We could maybe pass an empty prefix when we build the Horde_Cache_Storage_Memcache object based on the already prefixed Horde_Memcache in Horde_Core_Factory_Cache. We are only looking to the cache keys because we have a cache hit around 50% (which seems very low). Is this the expected hit rate?</description> 
   <pubDate>Mon, 23 May 2011 18:27:18 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t64982</link> 
  </item> 
   
  <item> 
   <title>Changes have been made in Git for this ticket:

Bug #10072: </title> 
   <description>Changes have been made in Git for this ticket:

Bug #10072: Fix memcache duplicate keys

 2 files changed, 7 insertions(+), 8 deletions(-)
http://git.horde.org/horde-git/-/commit/b28f5232ab1193cbd008a710d024de58c9b688df</description> 
   <pubDate>Tue, 24 May 2011 07:13:18 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t65006</link> 
  </item> 
   
  <item> 
   <title>&gt; We are back to this issue, and discovered a problem on the</title> 
   <description>&gt; We are back to this issue, and discovered a problem on the existing 
&gt; code (patch attached)

Slightly modified and committed (we shouldn&#039;t be changing the function signature because we are extending the method from the base class).  Thanks for tracking this down.

&gt; We agree that this is a conceptual problem, but it also doesn&#039;t make 
&gt; sense having the Horde_Cache_Storage_Memcache + Horde_Memcache 
&gt; duplicating the key prefix since one always calls the other.
&gt;
&gt; We could maybe pass an empty prefix when we build the 
&gt; Horde_Cache_Storage_Memcache object based on the already prefixed 
&gt; Horde_Memcache in Horde_Core_Factory_Cache. We are only looking to 
&gt; the cache keys because we have a cache hit around 50% (which seems 
&gt; very low). Is this the expected hit rate?

Memcache will have a mediocre hit rate because we do locking within memcache itself.  So there will be a lot of cache misses - every write will necessarily have a miss before.</description> 
   <pubDate>Tue, 24 May 2011 07:17:21 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t65007</link> 
  </item> 
   
  <item> 
   <title>&gt; Memcache will have a mediocre hit rate because we do locki</title> 
   <description>&gt; Memcache will have a mediocre hit rate because we do locking within 
&gt; memcache itself.  So there will be a lot of cache misses - every 
&gt; write will necessarily have a miss before.

Investigating this further we found out that it isn&#039;t related with locking, since setting $conf[&#039;memcache&#039;][&#039;large_items&#039;] to false will increase memcache hits to around 96%. So the problem is due to the get misses generated when trying to get the respective _os keys of items that are not large items.

We have been thinking about a fix for this problem, but since its not related with the original bug, i will post to the dev the solution we&#039;ve gotten to.
</description> 
   <pubDate>Tue, 24 May 2011 15:39:59 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t65030</link> 
  </item> 
   
  <item> 
   <title>&gt; We have been thinking about a fix for this problem, but si</title> 
   <description>&gt; We have been thinking about a fix for this problem, but since its not 
&gt; related with the original bug, i will post to the dev the solution 
&gt; we&#039;ve gotten to.

Thanks for your help in this ticket.
</description> 
   <pubDate>Tue, 24 May 2011 16:07:31 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10072#t65034</link> 
  </item> 
   
   
 
 </channel> 
</rss> 
