We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Error upgrading 1.3 to 2.0 REDIS

Hello , I updated my Phalcon from 1.3 to 2.0.6. In version 1.3 this code works fine:

    $di->set('session', function() {
        $session = new Phalcon\Session\Adapter\Redis(array(
            'path' => "tcp://XXX.XXX.157.108:6379?weight=1"
        ));
        @$session->start();
        return $session;
    });

Now my application displays this error:

'Could not connect to the Redisd server 127.0.0.1:6379' in phalcon/cache/backend/redis.zep:118

Why 127.0.0.1 ?



6.9k
Accepted
answer
edited Aug '15

It looks like this adapter was added to the actual Phalcon library itself as of 2.0.6, and you were previously using the Incubator version. I can't find the library documented anywhere, but it definitely exists: https://github.com/phalcon/cphalcon/blob/master/phalcon/session/adapter/redis.zep

It looks like usage would be something similar to

    $di->set('session', function() {
        $session = new Phalcon\Session\Adapter\Redis(array(
            'host' => 'XXX.16.157.108',
            'port' => 6379,
            'persistent' => true
        ));
        return $session;
    });


3.8k

Nice, thank you Mitchell :)

It looks like this adapter was added to the actual Phalcon library itself as of 2.0.6, and you were previously using the Incubator version. I can't find the library documented anywhere, but it definitely exists: https://github.com/phalcon/cphalcon/blob/master/phalcon/session/adapter/redis.zep

It looks like usage would be something similar to

   $di->set('session', function() {
       $session = new Phalcon\Session\Adapter\Redis(array(
           'host' => 'XXX.16.157.108',
          'port' => 6379,
          'persistent' => true
       ));
       return $session;
   });