0

我在一个项目中有一个 MVC 结构,其中有一个更改下拉列表,我将其称为 Controller,如下所示。

Javascript代码

function getData(newSelection)//This will get called on change of dropdown
$.ajax({
        type: 'POST',
        url: '/controller_name/perform',
        data: {
            'dropDownSelection': newSelection
        },
        success: function(data){     
            //alert(data);  /* always "failed" */                                      
            window.location.href=window.location;
        }
});

现在,在执行操作(即名为 PerformAction 的方法)中,调用正常进行。

执行动作

        /* somehow I am forming $key; trust me, its formed correct */
        $cache = Zend_Registry::get("cache");

        if($cache->delete($key))
            echo ("success");
        else
            echo ("failed");//this is what always returned
        exit;

但是在上面代码之后执行的一些代码中,我正在检查缓存是否退出,然后它显示为存在。

我正在检查的代码

        $cache = Zend_Registry::get("cache");
       //After building $key.                       
       //$cache->delete($key);    //Here it works

        $cacheResult = $cache->get($key);
        if (!empty($cacheResult)) ) {
           //exit("here it is coming, which I dont want for certain situation");
            return $cacheResult;
        }
        $reslut = /* Now I am building new result as per new selection from dropdown */
        $cache->set($key,$result,MEMCACHE_COMPRESSED,300);
        return $result;  //i want this to be returned instead of cached result

所以这就是场景。如果我从 $cache->delete($key); 中删除评论,我想获得使用下拉列表中的新选择构建的新结果;上面它总是会删除缓存,但我不想要这个。我想知道我哪里出错了还是因为 AJAX?

4

0 回答 0