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

Redis Queue

Hello, i am looking for redis queue driver, if there is not exist any where, I am interested to create a redis queue driver for cross-platform business (beanstalkd doesnot support windows) is there any interface i can follow?



36.0k
edited May '14

Hi, Redis is really simple to implement in your app. Just use https://github.com/nicolasff/phpredis:

$di->setShared('redis', function() {
    $redis = new Redis();
    $redis->pconnect(YOUR_HOST, YOUR_PORT);
    return $redis;
});

Offtop: I advise you to use Phpredis with Igbinary (https://github.com/igbinary/igbinary). Just look here for Nikolaos's performance tests of serialization: https://www.niden.net/2011/11/fast-serialization-of-data-in-php-how.html.



16.3k

Thanks before, but i am not asking how to use redis but how to make a redis queue driver on phalcon.



36.0k

Ok. What your Redis queue driver will do? How it will look?



16.3k

anything what phalcon beanstalkd does



19.9k
edited May '14

in order to define an object of redis like what aavolkoff mentioned in his post, where should I copy all my phpredis files and directories? ( in phalcon file structure )



36.0k

Ali-Azmoud, I told about phpredis that is just PHP-extesion (https://github.com/nicolasff/phpredis). It is only 1 file "redis.so" (linux) or "redis.dll" (windows). Copy it to PHP "ext" folder )))

May be you asked about "Predis" (https://github.com/nrk/predis) that is PHP-wrapper for phpredis?



36.0k

Sum, Ok, I understand that you want to create "yet another redis queue" :)

I think: Redis is just NoSQL db and Redis's aim is to store data in RAM. For message queue proper way is to use MQ services like beanstalkd or rabitMQ or gearman or... They will be much faster than self-maded Redis-powered queue service.



16.3k
edited May '14

Redis is not only store in RAM. I have used redis as message queue on my project [Laravel]

Redis supports in-memory persistent storage on disk.

Redis supports the writing of its data to disk automatically in two different ways, and can store data in four structures in addition to plain string keys as memcached does. These and other differences allow Redis to solve a wider range of problems, and allow Redis to be used either as a primary database or as an auxiliary databases with other storage systems

Quote from Redis in Action Book

You could, of course, implement your own queue using Redis (the list data type is very suitable for that purpose) but perhaps you should consider looking into a ready-made solution such as resque. This library essentially lets you manage queues on top of Redis from PHP.



16.3k