I don't understand the purpose of this function. Looks like it's checking to see if you can NOT put something in cache, and returning success if that is the case:
- clear cache id "flush-page-cache-test" from cache
- try to store a value in that cid
- get the value from that cid
- if the value you get back from cache is NOT the same as what you tried to store, return success
What is the purpose of that? Why should we not be able to store a value and get it back?
Comments
Comment #1
jrockowitz commentedTo clear a page's cache the flush_page_cache.module attempts to force cache_get() to always return NULL. The assumption and common practice is when cache_get() returns NULL the caller function/module will re-generate and re-cache the data. This module is not actually clearing cached page data but forcing all the cached data on a page to be re-built.
Since Drupal's database cache mechanism can be replaced with memcache or APC, the flush_page_cache_test_object_cache_disabled() function is testing that cache_get() is actual being disabled (returning NULL) as intended.
During the development of the module iamEAP and myself struggled with getting this code to work properly, which is why I added this function to insure that the module is continually confirming that it is working as expected.
Comment #2
bwinett commentedAh, I get it. Thanks for the explanation.
We are using memcache, so we have not changed our settings.php file.
When I clear the cache for a page, I see the message "Failed to flush all cached objects for this page. Please contact the administrator", indicating that the test failed.
Comment #3
jrockowitz commentedI will test it tomorrow. BTW, are you using the most recent version of the memcache module?
Comment #4
jrockowitz commentedSo I was able to test flushing the page for memache 6.x-1.9 and 6.x-1.10 and it works without any problem or error message. I definitely need to the know what version you are running.
Comment #5
bwinett commentedThanks for your help. We're running Memcache 6.x-1.9
Comment #6
jrockowitz commentedAre you using both database and memcache for caching or just memcache?
Could you please post your memcache config information?
Comment #7
bwinett commentedWe use only memcached, not a mix of db and memcached.
We run memcache-1.4.7/bin/memcached -v -m256 –d, all in one bin.
Php.ini configuration for memcache:
extension=memcache.so
memcache.hash_strategy="consistent"
settings.php configuration for memcache:
$conf = array(
'cache_inc' => './sites/all/modules/memcache/memcache.inc',
'memcache_stampede_protection' => TRUE,
'lock_inc' => './sites/all/modules/memcache/memcache-lock.inc',
'memcache_persistent' => TRUE,
'webform_allowed_tags' => array('a', 'em', 'strong', 'code', 'img', 'p', 'br'),
);
Comment #8
jrockowitz commentedI wasn't aware of the stampede protection in memcache. It is something I will probably implement on my site in the next few weeks. My guess is the cached data is not being replaced when cache_set() is being called.
Originally, I wanted to avoid telling people to hack their 'memcache.inc' file but I think if you put the below snippet in the beginning of cache_get() in 'memcache.inc', the page's cache will be be completely flushed.
This hack might be the best way to insure that the page's cache is cleared for any custom 'cache_inc' file provided by a contrib module. Can please test this solution out on your site?
Thanks
Comment #9
bwinett commentedThis worked for us. Thanks!
Comment #10
jrockowitz commentedSo I updated the module and post a new 6.x-1.beta2 release which uses this solution/hack since it insures that this module will always work as expected.
My assumption is that anyone using a contrib cache module will have a reasonable enough level of PHP skill to implement the code.
Comment #11
jrockowitz commentedSo, I updated/hacked my memcache.inc on a production site and the below cache_clear_all($cid, $table) call broke my site, basically cached data was being deleted but not regenerated. I am using multiple bins on remote server which might be part of the problem.
For now, I am going to recommend you use the same code without clear_cache_all().