aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/feedController.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-10-05 21:03:13 +0200
committerGravatar GitHub <noreply@github.com> 2016-10-05 21:03:13 +0200
commit11687f01f87799092954fd00db68aaf581c75ffd (patch)
tree735601471324914a9351a2e88291ca6bd8f8ce13 /app/Controllers/feedController.php
parent76c4a9aec1ae6b11efbeda16e639b47b9a5e793f (diff)
parent1df76fb6b5bd3dced52bd3b41eda54a518bd399b (diff)
Merge pull request #1280 from Alkarex/multiuser-optimisation
Take better advantage of other users refresh
Diffstat (limited to 'app/Controllers/feedController.php')
-rwxr-xr-xapp/Controllers/feedController.php21
1 files changed, 18 insertions, 3 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index c2a22aeb3..dadc8aa83 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -242,7 +242,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$feeds[] = $feed;
}
} else {
- $feeds = $feedDAO->listFeedsOrderUpdate(FreshRSS_Context::$user_conf->ttl_default);
+ $feeds = $feedDAO->listFeedsOrderUpdate(-1);
}
// Calculate date of oldest entries we accept in DB.
@@ -266,6 +266,21 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
continue; //When PubSubHubbub is used, do not pull refresh so often
}
+ $mtime = 0;
+ $ttl = $feed->ttl();
+ if ($ttl == -1) {
+ continue; //Feed refresh is disabled
+ }
+ if ($feed->lastUpdate() + 10 >= time() - ($ttl == -2 ? FreshRSS_Context::$user_conf->ttl_default : $ttl)) {
+ //Too early to refresh from source, but check whether the feed was updated by another user
+ $mtime = $feed->cacheModifiedTime();
+ if ($feed->lastUpdate() + 10 >= $mtime) {
+ continue; //Nothing newer from other users
+ }
+ //Minz_Log::debug($feed->url() . ' was updated at ' . date('c', $mtime) . ' by another user');
+ //Will take advantage of the newer cache
+ }
+
if (!$feed->lock()) {
Minz_Log::notice('Feed already being actualized: ' . $feed->url());
continue;
@@ -358,7 +373,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$entryDAO->addEntry($entry->toArray());
}
}
- $entryDAO->updateLastSeen($feed->id(), $oldGuids);
+ $entryDAO->updateLastSeen($feed->id(), $oldGuids, $mtime);
}
if ($feed_history >= 0 && rand(0, 30) === 1) {
@@ -377,7 +392,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
}
}
- $feedDAO->updateLastUpdate($feed->id(), 0, $entryDAO->inTransaction());
+ $feedDAO->updateLastUpdate($feed->id(), false, $entryDAO->inTransaction(), $mtime);
if ($entryDAO->inTransaction()) {
$entryDAO->commit();
}