简体   繁体   中英

Cache not working

I have the following function, but it is not caching. Is there something I'm missing? Environment: Doctrine Common and DBAL, PHP, MySQL. Should I not have the Cache ID a variable?

function getGeo($latitude, $longitude, $radius, $numResults, $volunteerPid, $startPosition, $pageSize)
    {
        $cacheDriver = new Doctrine\Common\Cache\ArrayCache();
        $geoQuery = $cacheDriver->fetch($volunteerPid);
        if ($geoQuery === false) {
            $geoQuery = $this->connection->prepare("call sproc_qryGeo($latitude, $longitude, $radius, $numResults, $volunteerPid, $startPosition, $pageSize)");
            $cacheDriver->save($volunteerPid, $geoQuery);
            echo "NOT CACHED";
        }
        return $geoQuery;
    }

As comes from cache types definintions on Doctrine site ArrayCache has a lifetime of a request. So, after you reload the page - your cache is gone .

So, if this is your case - think of another cache storage, Doctrine supports a bunch of them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM