From: Andrew Dolgov Date: Sat, 25 Aug 2007 16:24:18 +0000 (+0100) Subject: implement SIMPLEPIE_CACHE_DIR X-Git-Tag: 1.2.15~44 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=c7d57b66904e894ac6d33c5caaffb94bcb450c15;p=tt-rss.git implement SIMPLEPIE_CACHE_DIR --- diff --git a/config.php-dist b/config.php-dist index 0cd257be..a011b0d6 100644 --- a/config.php-dist +++ b/config.php-dist @@ -163,6 +163,9 @@ // to any feeds using HTTP Digest authentication and Magpie XML parsing // errors are bothering you too much, you can try enabling SimplePie. + define('SIMPLEPIE_CACHE_DIR', '/var/tmp/simplepie-ttrss-cache'); + // Cache directory for RSS feeds when using SimplePie + define('COUNTERS_MAX_AGE', 365); // Hard limit for unread counters calculation. Try tweaking this // parameter to speed up tt-rss when having a huge number of articles diff --git a/functions.php b/functions.php index 2aac7f3d..8cb2b544 100644 --- a/functions.php +++ b/functions.php @@ -207,6 +207,25 @@ (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0"); } + function get_feed_update_interval($link, $feed_id) { + $result = db_query($link, "SELECT owner_uid, update_interval FROM + ttrss_feeds WHERE id = '$feed_id'"); + + if (db_num_rows($result) == 1) { + $update_interval = db_fetch_result($result, 0, "update_interval"); + $owner_uid = db_fetch_result($result, 0, "owner_uid"); + + if ($update_interval != 0) { + return $update_interval; + } else { + return get_pref($link, 'DEFAULT_UPDATE_INTERVAL', $owner_uid, false); + } + + } else { + return -1; + } + } + function update_all_feeds($link, $fetch, $user_id = false, $force_daemon = false) { if (WEB_DEMO_MODE) return; @@ -441,11 +460,26 @@ if (!ENABLE_SIMPLEPIE) { $rss = fetch_rss($fetch_url); } else { + if (!is_dir(SIMPLEPIE_CACHE_DIR)) { + mkdir(SIMPLEPIE_CACHE_DIR); + } + $rss = new SimplePie(); $rss->set_useragent(SIMPLEPIE_USERAGENT . MAGPIE_USER_AGENT_EXT); $rss->set_timeout(MAGPIE_FETCH_TIME_OUT); $rss->set_feed_url($fetch_url); $rss->set_output_encoding('UTF-8'); + + if (defined('DAEMON_EXTENDED_DEBUG') || $_GET['xdebug']) { + _debug("feed update interval (sec): " . + get_feed_update_interval($link, $feed)*60); + } + + if (is_dir(SIMPLEPIE_CACHE_DIR)) { + $rss->set_cache_location(SIMPLEPIE_CACHE_DIR); + $rss->set_cache_duration(get_feed_update_interval($link, $feed) * 60); + } + $rss->init(); } diff --git a/update_daemon.php b/update_daemon.php index ce5d2535..50d13191 100644 --- a/update_daemon.php +++ b/update_daemon.php @@ -9,6 +9,7 @@ declare(ticks = 1); define('MAGPIE_CACHE_DIR', '/var/tmp/magpie-ttrss-cache-daemon'); + define('SIMPLEPIE_CACHE_DIR', '/var/tmp/simplepie-ttrss-cache-daemon'); define('DISABLE_SESSIONS', true); require_once "version.php";