More memcache cleanup and add threads to memcache.
This commit is contained in:
parent
ea5a32cb1e
commit
b0b1ba8b69
|
@ -67,7 +67,22 @@ function thread_pageselect($group, $article_count, $first)
|
||||||
*/
|
*/
|
||||||
function thread_cache_load($group)
|
function thread_cache_load($group)
|
||||||
{
|
{
|
||||||
global $spooldir, $compress_spoolfiles;
|
global $spooldir, $config_dir, $logdir, $compress_spoolfiles;
|
||||||
|
if (file_exists($config_dir . '/memcache.inc.php')) {
|
||||||
|
include $config_dir . '/memcache.inc.php';
|
||||||
|
}
|
||||||
|
// Check memcache
|
||||||
|
if ($memcacheD) {
|
||||||
|
$key = 'thread_cache_load-' . $group;
|
||||||
|
if ($headers = unserialize($memcacheD->get($key))) {
|
||||||
|
if ($headers['memcache_time'] >= filemtime($spooldir . '/' . $group . '-lastupdate.dat')) {
|
||||||
|
if ($enable_memcache_logging) {
|
||||||
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " Using $key from memcache", FILE_APPEND);
|
||||||
|
}
|
||||||
|
return $headers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$database = $spooldir . '/' . $group . '-data.db3';
|
$database = $spooldir . '/' . $group . '-data.db3';
|
||||||
$table = "threads";
|
$table = "threads";
|
||||||
if ($dbh = threads_db_open($database, $table)) {
|
if ($dbh = threads_db_open($database, $table)) {
|
||||||
|
@ -79,6 +94,18 @@ function thread_cache_load($group)
|
||||||
}
|
}
|
||||||
$dbh = null;
|
$dbh = null;
|
||||||
}
|
}
|
||||||
|
if ($memcacheD) {
|
||||||
|
$nicole = $memcacheD->delete($key);
|
||||||
|
$headers['memcache_time'] = time();
|
||||||
|
$memcacheD->add($key, serialize($headers), $memcache_ttl);
|
||||||
|
if ($enable_memcache_logging) {
|
||||||
|
if ($nicole) {
|
||||||
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " Updated $key in memcache", FILE_APPEND);
|
||||||
|
} else {
|
||||||
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " Wrote $key to memcache", FILE_APPEND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return ($headers);
|
return ($headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,11 +719,11 @@ function thread_format_subject($c, $group, $highlightids = false)
|
||||||
$offset = $CONFIG['timezone'] * 60;
|
$offset = $CONFIG['timezone'] * 60;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
if ($c->isReply) {
|
* if ($c->isReply) {
|
||||||
$re = "Re: ";
|
* $re = "Re: ";
|
||||||
} else {
|
* } else {
|
||||||
$re = "";
|
* $re = "";
|
||||||
}
|
* }
|
||||||
*/
|
*/
|
||||||
$re = "";
|
$re = "";
|
||||||
// is the current article to be highlighted?
|
// is the current article to be highlighted?
|
||||||
|
|
|
@ -643,14 +643,6 @@ function groups_show($gruppen)
|
||||||
$found = 1;
|
$found = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$result = $memcacheD->delete($lar_memcache);
|
|
||||||
if ($enable_memcache_logging) {
|
|
||||||
if ($result) {
|
|
||||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " Deleted $lar_memcache from memcache", FILE_APPEND);
|
|
||||||
} else {
|
|
||||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " Failed to delete (or not found) $lar_memcache from memcache", FILE_APPEND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($lastarticleinfo);
|
unset($lastarticleinfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -659,12 +651,15 @@ function groups_show($gruppen)
|
||||||
$database = $spooldir . '/articles-overview.db3';
|
$database = $spooldir . '/articles-overview.db3';
|
||||||
$table = 'overview';
|
$table = 'overview';
|
||||||
$overview_dbh = overview_db_open($database);
|
$overview_dbh = overview_db_open($database);
|
||||||
$overview_query = $overview_dbh->prepare('SELECT * FROM overview WHERE newsgroup=:newsgroup ORDER BY CAST(date AS int) DESC LIMIT 2');
|
$overview_query = $overview_dbh->prepare('SELECT * FROM overview WHERE newsgroup=:newsgroup ORDER BY CAST(date AS int) DESC LIMIT 5');
|
||||||
$overview_query->execute([
|
$overview_query->execute([
|
||||||
'newsgroup' => $g->name
|
'newsgroup' => $g->name
|
||||||
]);
|
]);
|
||||||
$found = 0;
|
$found = 0;
|
||||||
while ($row = $overview_query->fetch()) {
|
while ($row = $overview_query->fetch()) {
|
||||||
|
if($row['date'] > time()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$found = 1;
|
$found = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -674,12 +669,16 @@ function groups_show($gruppen)
|
||||||
$lastarticleinfo = $row;
|
$lastarticleinfo = $row;
|
||||||
if ($memcacheD) {
|
if ($memcacheD) {
|
||||||
touch($groupfile, $lastarticleinfo['date']);
|
touch($groupfile, $lastarticleinfo['date']);
|
||||||
$memcacheD->delete($lar_memcache);
|
$nicole = $memcacheD->delete($lar_memcache);
|
||||||
$memcacheD->add($lar_memcache, serialize($row), $memcache_ttl);
|
$memcacheD->add($lar_memcache, serialize($row), $memcache_ttl);
|
||||||
|
if ($nicole) {
|
||||||
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " Updated $lar_memcache in memcache", FILE_APPEND);
|
||||||
|
} else {
|
||||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " Wrote $lar_memcache to memcache", FILE_APPEND);
|
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " Wrote $lar_memcache to memcache", FILE_APPEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$new = false;
|
$new = false;
|
||||||
$new_style_on = '';
|
$new_style_on = '';
|
||||||
$new_style_off = '';
|
$new_style_off = '';
|
||||||
|
@ -2345,6 +2344,12 @@ function insert_article_from_array($this_article, $check_duplicates = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($this_article['epochdate'] > time()) {
|
||||||
|
echo "\n(newsportal)Article date in future. Skipping: " . $group . ":" . $this_article['mid'];
|
||||||
|
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Article date in future. Skipping: " . $group . ":" . $this_article['mid'], FILE_APPEND);
|
||||||
|
return "441 Insert failed (article date in future)\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
// Open articles Database
|
// Open articles Database
|
||||||
if ($CONFIG['article_database'] == '1') {
|
if ($CONFIG['article_database'] == '1') {
|
||||||
$article_dbh = article_db_open($spooldir . '/' . $group . '-articles.db3');
|
$article_dbh = article_db_open($spooldir . '/' . $group . '-articles.db3');
|
||||||
|
@ -2407,7 +2412,11 @@ function insert_article_from_array($this_article, $check_duplicates = true)
|
||||||
$statusdate = time();
|
$statusdate = time();
|
||||||
$statusreason = "imported";
|
$statusreason = "imported";
|
||||||
add_to_history($group, $this_article['local'], $this_article['mid'], $status, $statusdate, $statusreason, $statusnotes);
|
add_to_history($group, $this_article['local'], $this_article['mid'], $status, $statusdate, $statusreason, $statusnotes);
|
||||||
|
if ($this_article['epochdate'] < time()) {
|
||||||
touch($spooldir . '/' . $group . '-lastupdate.dat', $this_article['epochdate']);
|
touch($spooldir . '/' . $group . '-lastupdate.dat', $this_article['epochdate']);
|
||||||
|
} else {
|
||||||
|
touch($spooldir . '/' . $group . '-lastupdate.dat', time());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_deleted_post($group, $number)
|
function is_deleted_post($group, $number)
|
||||||
|
|
|
@ -11,7 +11,7 @@ if(!$enable_memcache) {
|
||||||
$server = '127.0.0.1';
|
$server = '127.0.0.1';
|
||||||
$port = 11211;
|
$port = 11211;
|
||||||
|
|
||||||
// Log all hits
|
// Log all hits (log file may be large)
|
||||||
$enable_memcache_logging = false;
|
$enable_memcache_logging = false;
|
||||||
|
|
||||||
// Time in seconds to cache data
|
// Time in seconds to cache data
|
||||||
|
|
Loading…
Reference in New Issue