Use memcache for get_newsgroups_by_msgid.
This commit is contained in:
parent
9825d0d43d
commit
611a0279d9
|
@ -1602,7 +1602,19 @@ function get_date_interval($value)
|
|||
|
||||
function get_newsgroups_by_msgid($msgid, $noarray = false)
|
||||
{
|
||||
global $spooldir, $CONFIG;
|
||||
global $spooldir, $config_dir, $logdir, $CONFIG;
|
||||
if (file_exists($config_dir . '/memcache.inc.php')) {
|
||||
include $config_dir . '/memcache.inc.php';
|
||||
}
|
||||
if ($memcacheD) {
|
||||
$key = 'get_newsgroups_by_msgid-' . $msgid;
|
||||
if ($groups = $memcacheD->get($key)) {
|
||||
if ($enable_memcache_logging) {
|
||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache hit) $key", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! $groups) {
|
||||
$database = $spooldir . '/articles-overview.db3';
|
||||
$table = 'overview';
|
||||
$overview_dbh = overview_db_open($database, $table);
|
||||
|
@ -1620,6 +1632,13 @@ function get_newsgroups_by_msgid($msgid, $noarray = false)
|
|||
$groups = null;
|
||||
}
|
||||
$overview_dbh = null;
|
||||
if ($groups && $memcacheD) {
|
||||
$nicole = $memcacheD->add($key, $groups, $memcache_ttl);
|
||||
if ($enable_memcache_logging && $nicole) {
|
||||
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " Wrote $key", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($noarray) {
|
||||
return (implode(",", $groups));
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue