Make caching for ban list (#1269)

This commit is contained in:
Roman Kelesidis 2023-12-27 00:16:54 +07:00 committed by GitHub
commit 66083cabad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 31 deletions

View file

@ -2183,15 +2183,13 @@ function user_birthday_icon($user_birthday, $user_id): string
*/
function getUserBanInfo(int $userId): ?array
{
return DB()->fetch_row("SELECT * FROM " . BB_BANLIST . " WHERE ban_userid = $userId LIMIT 1");
}
global $datastore;
/**
* Returns information about all bans
*
* @return array|null
*/
function getAllBans(): ?array
{
return DB()->fetch_rowset("SELECT * FROM " . BB_BANLIST);
// Get bans info from datastore
if (!$bans = $datastore->get('ban_list')) {
$datastore->update('ban_list');
$bans = $datastore->get('ban_list');
}
return $bans[$userId] ?? [];
}