Drupal feedapi my feed items arent refreshing
This post provides a little bit of documentation about the feedapi.
There is no setting to choose how long your feed items are cached. The default cache time is 3600 sec. Which mean when you re testing the feedapi your feed isnt updated immediatly.
I made a feature request to include this. You can allways adapt the parser simple pie module. Following function is adapted wich sets the cache time to 150sec. (feedapi/parser_simplepie/parser_simplepie.module line 187)
<?php
/**
* Set SimplePie setting
* @param $url
* The feed's url
* @return
* SimplePie object
*/
function _parser_simplepie_get_parser($url, $enable_cache = TRUE) {
require_once(drupal_get_path('module', 'parser_simplepie') .'/simplepie.inc');
$parser = new SimplePie();
$parser->set_feed_url($url);
$parser->set_timeout(15);
$parser->set_stupidly_fast(TRUE);
$parser->encode_instead_of_strip(FALSE);
$cache_location = _parser_simplepie_sanitize_cache();
$parser->enable_cache($cache_location !== FALSE ? $enable_cache : FALSE);
//This sets the cache time
$parser->set_cache_duration(150);
$parser->set_cache_location($cache_location);
$parser->init();
return $parser;
}
?>
Something intersting I saw was the technique which was used to determine if a serie of feeds was changed and needed an update. All the feed items where serialized and hashed with the md5 algoritme. The old hash string was compared with the new one to see if something was updated.
From feedapi module: line 1166-1173
<?php
$hash_old = $feed->hash;
$feed = _feedapi_call_parsers($feed, $feed->parsers, $feed->half_done);
if (is_object($feed)) {
$feed->hash = md5(serialize($feed->items));
}
// Step 3: See, whether feed has been modified.
if ($feed === FALSE || $hash_old == $feed->hash) {
//...
?>
Add new comment