Add search cache lifetime setting to admin panel

This commit is contained in:
Visman 2023-07-14 17:31:53 +07:00
parent ddbc87b031
commit 67dd3da824
6 changed files with 24 additions and 3 deletions

View file

@ -1576,6 +1576,7 @@ class Install extends Admin
'i_upload_img_quality' => 75,
'i_upload_img_axis_limit' => 1920,
's_upload_img_outf' => 'webp,jpg,png,gif',
'i_search_ttl' => 900,
];
foreach ($forkConfig as $name => $value) {

View file

@ -61,6 +61,7 @@ class Options extends Admin
'i_timeout_visit' => 'required|integer|min:0|max:99999',
'i_timeout_online' => 'required|integer|min:0|max:99999|check_timeout',
'i_redirect_delay' => 'required|integer|min:0|max:99999',
'i_search_ttl' => 'required|integer|min:300|max:99999',
'b_show_user_info' => 'required|integer|in:0,1',
'b_show_post_count' => 'required|integer|in:0,1',
'i_topic_review' => 'required|integer|min:0|max:50',
@ -286,6 +287,14 @@ class Options extends Admin
'caption' => 'Redirect time label',
'help' => 'Redirect time help',
],
'i_search_ttl' => [
'type' => 'number',
'min' => '300',
'max' => '99999',
'value' => $config->i_search_ttl,
'caption' => 'Search cache lifetime label',
'help' => 'Search cache lifetime help',
],
],
];

View file

@ -724,6 +724,7 @@ class Update extends Admin
$config = $this->c->config;
$config->s_upload_img_outf = 'webp,jpg,png,gif';
$config->i_search_ttl = 900;
$config->save();

View file

@ -20,8 +20,6 @@ use RuntimeException;
class Execute extends Method
{
const CACHE_TIMEOUT = 300;
protected string $queryIdx;
protected string $queryCJK;
protected int $sortType;
@ -43,7 +41,7 @@ class Execute extends Method
throw new RuntimeException('No query data');
}
$delimiter = \time() - self::CACHE_TIMEOUT;
$delimiter = \time() - $this->c->i_search_ttl;
$this->words = [];
$this->stmtIdx = null;
$this->stmtCJK = null;

View file

@ -440,3 +440,9 @@ msgstr "Allow users to login/register on this bulletin board using accounts on t
msgid "Configure providers"
msgstr "Configure providers"
msgid "Search cache lifetime label"
msgstr "Search cache lifetime"
msgid "Search cache lifetime help"
msgstr "Search query caching time in seconds."

View file

@ -440,3 +440,9 @@ msgstr "Разрешить пользователям вход/регистра
msgid "Configure providers"
msgstr "Настроить провайдеров"
msgid "Search cache lifetime label"
msgstr "Время жизни кеша поиска"
msgid "Search cache lifetime help"
msgstr "Время кэширования поисковых запросов в секундах."