FriendFeed cache not clearing on Drupal 5.7
| Project: | FriendFeed |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Jump to:
This one has me baffled, but I'm pretty sure it's not a FriendFeed issue. I want to log it here in case somebody else encounters it, but I think it might either be a core issue, or another of my contrib modules is breaking things.
The problem is that once my FriendFeed items get loaded into the cache, they're not expiring. I poked around for over an hour, and there seem to be some oddities regarding cache handling that are getting more attention in D6 and D7 right now, which left me with one or two short-term options.
The first option would be to not use the cache by defaulting $reset_cache = TRUE in the parameters for friendfeed_user_feed, but I didn't want to do that.
Cached items are supposed to be cleared during the call to cache_get, but it appears that it'll only do that if the cache has been cleared once before and the cache_flush variable is set. Well, for some reason on my site, it's not set, so the cache doesn't clear. I came up with an ugly hack was to add code that I found in #227228: cache_clear_all and cache_get fail to clear caches when Minimum cache lifetime is on to make sure the cache_flush timer is set before calling cache_get. I also set it one hour in the past so that I wouldn't get bitten by cache_lifetime, either.
I do not recommend this fix be committed, because I think it's treating a symptom and not the real problem. (Which is why I didn't roll it as a proper patch.) However, if people want to use the 5.x version of this module in the meantime, I think something like this will be necessary.
--- friendfeed.module.orig 2008-07-08 21:11:21.000000000 -0400
+++ friendfeed.module 2008-07-08 23:18:41.000000000 -0400
@@ -177,6 +177,12 @@ function friendfeed_block($op = 'list',
* Retrieve a given user's FriendFeed status.
*/
function friendfeed_user_feed($username, $authkey = '', $service = NULL, $start = 0, $num = 30, $reset_cache = FALSE) {
+ // Ugly hack. Don't want this to be permanent, but not sure how to work around it.
+ $cache_flush = variable_get('cache_flush', 0);
+ if ($cache_flush == 0) {
+ variable_set('cache_flush', time() - 3600);
+ }
+
static $feeds = array();
// Load the feed from the cache if needed
$key = $username .'|'. $authkey .'|'. $service .'|'. $start .'|'. $num;Please let me know if I overlooked something stupidly obvious. This is my first attempt at doing anything related to Drupal's caching system, so I have no prior experience to go on.
Thanks,
Micah

#1
Hmmm.... now even that hack seems to have stopped working. I don't know why this isn't working right. Too late to keep at it tonight. I set
$reset_cache = TRUEfor now as a bigger workaround. Will try again with this later.Micah
#2
Hmmmm.... I've noticed that FriendFeed has been failing updates on my own site http://robloach.net/about . Hmmm.
#3
Rob, I noticed that Drupal 5.8 had some fixes for cache cleanup. Didn't look to see if there were similar fixes in 6.3. I'll test this against 5.8 before going any further. For now, I've just disabled the caching in friendfeed.module and it's working fine.
#4
My Friendfeed block hasn't been updating instantly. Maybe it has to do with the cache problem? I'm on Drupal 5.8 using the latest version.