1

我在尝试将 cacheengine 与 Xcache 一起使用时遇到问题:

当我使用 File 或 Memcache 时,缓存引擎工作正常,它保存数据并从缓存中成功读取它们。

当我尝试使用 Xcache 时,它​​会保存数据(Cache::Write() 返回 1)但 Cache::read() 什么也不返回。

在我的 bootstrap.php 中:

Cache::config('12h', array(
                          'engine'   => 'Xcache',
                          'duration' => '+12 hours',
//                          'path'     => CACHE,
//                          'prefix'   => 'cake_12h_'
                     ));

在 core.php 中:

Cache::config('Xcache', array(
                             'engine' => 'Xcache', //[required]
                             'duration'    => 3600, //[optional]
                             'probability' => 100, //[optional]
                        ));

我使用缓存的主要功能:

public function pronostics() {

        $this->set('title_for_layout', 'Pronostics');

        if ($this->_isUserLogged()) {

            $pronostics = Cache::read('pronostics', '12h');

            if (!$pronostics || isset($this->request->query['force'])) {
                $loginUrl = self::SITE_API_URL . '/api/getPronostics?auth_key=123&user_id=' . self::SITE_ID;

                list($httpCode, $res) = $this->_curlIt($loginUrl, false, false);

                if ($httpCode === 200) {
                    $res = json_decode($res);
                    if (is_object($res) && $res->status == 'success') {

                        $pronostics = $res->pronostics;

                        $res = Cache::write('pronostics', $pronostics, '12h');
                        $this->log($res, 'curl');
                    } else {
                        $this->redirect(array('controller' => 'interactions', 'action' => 'pronostics'));
                    }
                }
            }

            $this->set('pronostics', $pronostics);

        } else {
            $this->Session->setFlash('Pour accéder aux pronostics, vous devez être identifié.', 'default', array(), 'error');
            $this->redirect(array('controller' => 'interactions', 'action' => 'index', '?' => array('login_error' => 1)));
        }
    }

你知道为什么 xcache 在我的情况下不起作用吗?谢谢。

4

0 回答 0