zeflex
zeflex

Reputation: 1527

Cakephp Caching using Xcache

I have an issue trying to use cacheengine with Xcache:

When I use File Or Memcache, the cache engine works fine, it save datas and read them successfully from cache.

When I try to use Xcache, it saves datas (Cache::Write() returns 1) but Cache::read() returns nothing.

In my bootstrap.php:

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

In the core.php:

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

The main function where I use cache:

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)));
        }
    }

Do you know why xcache does not works in my case ? Thanks.

Upvotes: 1

Views: 328

Answers (0)

Related Questions