简体   繁体   English

缓存不起作用

[英]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. 环境:Doctrine Common和DBAL,PHP,MySQL。 Should I not have the Cache ID a variable? 缓存ID是否应为变量?

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. 正如来自缓存类型的定义一样,Doctrine站点上的 ArrayCache具有请求的生存期。 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. 因此,如果您是这种情况,请考虑其他缓存存储,Doctrine支持其中的一堆。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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