Cache entries seem to stay in the cache despite being cleared with cache_clear_all with wildcard enabled.
Using regular Drupal caching cache clear as expected.
Reproducable with this code (I used hook_page_alter):
cache_clear_all('mystr_static', 'cache');
cache_clear_all('mystr', 'cache', TRUE);
$vars = array('mystr_perm', 'mystr_temp', 'mystr_time', 'mystr_static');
foreach ($vars as $key) {
$var = cache_get($key);
if ($var && $var->data) {
drupal_set_message($var->data);
}
}
cache_set('mystr_perm', 'permanent - this should not be visible', 'cache', CACHE_PERMANENT);
cache_set('mystr_temp', 'temporary - this should not be visible', 'cache', CACHE_TEMPORARY);
cache_set('mystr_time', 'time - this should not be visible', 'cache', time() + 1000);
cache_set('mystr_static', 'static - this should not be visible', 'cache', time() + 1000);
All texts should NOT be visible, however with the current version(s) only the exactly flushed key (mystr_static) is cleared. Do note that this required loading the page twice.
Comments
Comment #1
rbrandon commentedI am seeing the same behavior. When DB caching is turned on then:
cache_clear_all('mystr', 'my_cache_bin', TRUE);
Will delete all items prefixed with mystr. However with "my_cache_bin" using memcached the wildcard cache clear leaves the stale data in place.
Comment #2
timtrinidad commentedI'm not sure if this is the same issue - we're using memcache.inc with cache_backport on D6. I figured I'd post it in case someone else stumbles across the same issue with the same setup.
This would case a statically stored MemCacheDrupal object for the 'cache' bin with no loaded memcache_wildcard_flushes values. Other bins seemed not to have been affected.
Our solution for now was to move all the cache_{set,get,clear_all}('variables') calls to its own cache_variables bin so that the 'cache' object wouldn't be instantiated incorrectly.
Comment #3
markpavlitski commentedThis may be caused by these issue:
https://bugs.php.net/bug.php?id=58651
https://bugzilla.redhat.com/show_bug.cgi?id=638892
MemCacheDrupal::wildcards()sets an integer value directly, which is what triggers the issues above on PECL memcache versions prior to 3.0.5.The attached patch works around the issue by disabling compression for the PECL memcache library if the value sent to memcached is numeric.
A test case is included.
Comment #4
hefox commentedTo verify that one is experiencing this bug, run this
If the last line prints the stdClass like the second line, you're experiencing this issue. Add the patch and the last line should have no results.
Comment #5
markpavlitski commentedNeeds backport.
Comment #6
jeremy commentedIMO I'd rather just document that 3.0.5+ is required versus working around this (and possibly update the requirements hook to throw a warning when using an unsupported version). Anything we can do to simplify already complex code seems like a step in the right direction.
Comment #7
markpavlitski commentedIt's implicitly documented in the README that there may be issues with older versions of the PECL libraries, so we could just close the ticket.
Otherwise the attached patch makes it more obvious and adds a requirements check for Memcache 3.0.6+ and Memcached 2.0.1+ as per the README recommendation.
Comment #8
markpavlitski commentedComment #9
jeremy commentedThanks, committed:
http://drupalcode.org/project/memcache.git/commitdiff/92483f6
I also included the test, perhaps someday a 2.2.x release will fix this bug at which point we'd want to support it (2.2.7 does not).
Comment #10
jeremy commentedI updated this to also trigger an error when the memcache module is enabled:
http://drupalcode.org/project/memcache.git/commitdiff/27c2d0a
Comment #11
hefox commentedNote that I think I used this patch for use with acquia enviroment to my memory, not sure if the upgraded their memcache since.