@guruz hmmm. Logic in the original code is slightly morbid. Why do we return something that is not even set here?
In case of caching all mimetypes at once this part should be moved outside of 'if' condition that is used to fill the cache:
    function getSmth(){
        if (cache_empty()){
            //fill cache
        }
        if (foundInCache($key)){
            return $value;
        }  else {
            return null;
        }
    }