Serialize data for get_data_from_msgid cache.

This commit is contained in:
Retro_Guy 2024-06-18 03:44:07 -07:00
parent 47139a9467
commit 598ba842b3
1 changed files with 7 additions and 2 deletions

View File

@ -2634,12 +2634,17 @@ function get_data_from_msgid($msgid, $thisgroup = null)
if ($enable_cache) { if ($enable_cache) {
$row_cache = $cache_key_prefix . '_' . 'get_data_from_msgid-' . $msgid; $row_cache = $cache_key_prefix . '_' . 'get_data_from_msgid-' . $msgid;
if ($row = cache_get($row_cache, $memcacheD)) { if ($row = unserialize(gzuncompress(cache_get($row_cache, $memcacheD)))) {
if(isset($row['msgid'])) {
if ($enable_cache_logging) { if ($enable_cache_logging) {
file_put_contents($cache_log, "\n" . format_log_date() . " (cache hit) $row_cache", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " (cache hit) $row_cache", FILE_APPEND);
} }
return $row; return $row;
} }
} else {
file_put_contents($cache_log, "\n" . format_log_date() . " (cache update) $row_cache", FILE_APPEND);
cache_delete($row_cache, $memcacheD);
}
} }
$database = $spooldir . '/articles-overview.db3'; $database = $spooldir . '/articles-overview.db3';
@ -2664,7 +2669,7 @@ function get_data_from_msgid($msgid, $thisgroup = null)
$dbh = null; $dbh = null;
if ($found) { if ($found) {
if ($enable_cache) { if ($enable_cache) {
$nicole = cache_add($row_cache, $row, $cache_ttl, $memcacheD); $nicole = cache_add($row_cache, gzcompress(serialize($row)), $cache_ttl, $memcacheD);
if ($enable_cache_logging && $nicole) { if ($enable_cache_logging && $nicole) {
file_put_contents($cache_log, "\n" . format_log_date() . " (cache write) $row_cache", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " (cache write) $row_cache", FILE_APPEND);
} }