isn't present less code turns out
the code becomes more beautiful and more clear (this my personal judgement)
<?php
# old style
function getCategoryList()
{
    global $txt, $smcFunc;
    if (!($cats = cache_get_data('cats_list'))) {
        $cats = [];
        $q = $smcFunc['db_query']('', '
            SELECT cat.id, cat.name, ...',
            []
        );
        if (!$smcFunc['db_num_rows']($q))
            return [];
        while ($row = $smcFunc['db_fetch_assoc']($q)) {
            $cats[$row['id']] = $row;
        }
        $smcFunc['db_free_result']($q);
        cache_put_data('cats_list', $cats, 1800);
    }
   return $cats; 
}
# new style
function getMyCats2()
{
    return cache_remember_data('cats_list', 30, function()
    {
        global $txt, $smcFunc;
        $cats = [];
        $q = $smcFunc['db_query']('', '
            SELECT c.id, c.name, ...',
            []
        );
        if (!$smcFunc['db_num_rows']($q))
            return [];
        while ($row = $smcFunc['db_fetch_assoc']($q)) {
            $cats[$row['id']] = $row;
        }
        $smcFunc['db_free_result']($q);
        return $cats;
    });
}