Download & Extend

cache_get() not working properly due to a possible prefix problem

Project:Memcache API and Integration
Version:6.x-1.9
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

I just installed the memcache module and most things appear to be faster now that they are coming from cache. There are a few pieces of data that I would expect to come from the cache but are not. If I use memcache.db.in the values will at least pull from the database but ideally I'd like to use memcache.inc for better performance.

I set my data using the following function:

<?php
  cache_set
('yt_city_links_59', $myarray, 'cache', time()+(60*60*24)); // cache for 1 day
?>

I then read the data out using the following:

<?php
  $cache
= cache_get('yt_city_links_59', 'cache');
?>

This was all working fine until I tried using memcache.inc to increase performance. Here is a screenshot from the output of the memcache_admin module:
memcache cache_get miss

You'll notice that the yt_city_links_59 is a miss since it doesn't have a 1 next to it. I've tried a bunch on my own trying to get this value to be a hit instead of a miss but for some reason it never works. I noticed that there are some differences with the prefixing of the variables at times. For example, my yt_city_links_59 key is prefixed with 'yt_prod-cache-' but all the other values in the screenshot are prefixed with 'yt_prod-cache_'. It appears that for some reason the prefix is followed by an underscore in some cases and by a hyphen in other cases. I suspect that this could be a problem but I'm not sure.

I suspect that the reason memcache.db.inc is working is because it's falling back to the database table if the value can't be found in memcache.

Any help is greatly appreciated.

AttachmentSize
cache_get_miss.jpg38.25 KB

Comments

#1

The prefixing isn't different between the '-' and '_'.

yt_prod_cache-yt_city_links

vs.
yt_prod_cache_views-views_default

In both cases the format this is:

$prefix . '-' . $bin . '-' $key;

The reason it looks different is because in one case you have 'cache' as the bin, and in the other 'cache_views'.