Memcache cache result
===

Consider the following code:

    function getUser($uid) {
        global $_memcache;
        $u = $_memcache->get("user-".$uid);
        if( !$u) {
            $u = ... // get user from database
            $_memcache->set("user-".$uid,$u);
        }
        return $u;
    }

Now, this function will probably be called a LOT. For instance, on the forum it may be called 30+ times in a single pageload. Is it worth doing the following, or is Memcache already optimal enough?

    function getUser2($uid) {
        static $localcache = [];
        if( isset($localcache[$uid])) return $localcache[$uid];
        return $localcache[$uid] = getUser($uid);
    }