From 77e9a0294f2268a3383089024806ba153910503c Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 18 Oct 2023 20:27:12 +0300 Subject: [PATCH] cache getTopHostPages method results for 24 hours --- src/public/top.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/public/top.php b/src/public/top.php index 4627afd..2fa2729 100644 --- a/src/public/top.php +++ b/src/public/top.php @@ -5,6 +5,7 @@ require_once(__DIR__ . '/../config/app.php'); require_once(__DIR__ . '/../library/filter.php'); require_once(__DIR__ . '/../library/mysql.php'); require_once(__DIR__ . '/../library/sphinxql.php'); +require_once(__DIR__ . '/../../vendor/autoload.php'); // Connect Sphinx search server try { @@ -30,6 +31,18 @@ try { exit; } +// Connect Yggverse\Cache\Memory +try { + + $memory = new Yggverse\Cache\Memory(MEMCACHED_HOST, MEMCACHED_PORT, MEMCACHED_NAMESPACE, MEMCACHED_TIMEOUT + time()); + +} catch(Exception $e) { + + var_dump($e); + + exit; +} + // Define page basics $totalPages = $sphinx->getHostPagesTotal(); @@ -38,6 +51,7 @@ $placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the sprintf(_('Over %s pages or enter the new one...'), number_format($totalPages)), ]); + ?> @@ -245,7 +259,7 @@ $placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the
- getTopHostPages()) { ?> + getByMethodCallback($db, 'getTopHostPages', [], time() + 86400)) { ?>