We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.


I see there is an adapter for MongoDB. I prefer to use Redis. Is MongoDB adapter written in C? Right now I'm using \Predis via composer.

Is there any point in re-inventing the wheel to integrate into Phalcon in a C-type library when this library works quite fine? I don't know if speed would increase so much as Redis is already unbelievably fast.

Predis: https://github.com/nrk/predis


There doesn't seem to be a database adapter included with phalcon, however, given the modularity of phalconphp. You could use the adapter here, bot those are SESSION adapters only. Also, there only seems to be a mongodb cache adapter. If you'd be more speciffic about the kind of adapter you need, that'd allow me to give you a better answer.

All that the redis session adapter does is use redis's built in session handler, which IS written in c, and bundled within the redis php module.

As far as the database adapters (datasources) go, these are all of them, acording to the documentation.

Hope you find this answer useful.



edited Mar '14

Hi, I use on every my website redis registering Redis in bootstrap in DI I use phpredis extension https://github.com/nicolasff/phpredis

$di->setShared("redis", function() {
        $redis = new Redis();
        $redis->connect('', 6379);
        $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);
        $redis->setOption(Redis::OPT_PREFIX, $_SERVER['HTTP_HOST'].":");
        return $redis;

then you can use it everywhere


Thanks that will work perfectly :)