Wallogit.com
2017 © Pedro Peláez
A PHP driver for the okq persistent queue
A PHP driver for the okq persistent queue., (*1)
okq uses the redis protocol and calling conventions as it's interface, so any standard redis client can be used to interact with it. This package wraps around a normal redis driver, however, to provide a convenient interface to interact with. Specifically, it creates a simple interface for event consumers to use so they retrieve events through a channel rather than implementing that logic manually every time., (*2)
Commands for okQ are implemented on the Okq class parameters resemble those
of the okQ command itself. The Okq class extends phpredis/Redis
and can be constructed using the same arguments:, (*3)
$q = new Okq();
$q->connect('127.0.0.1', 4777);
Then to add jobs you just run the command!, (*4)
$event = array('test' => 1);
$eventId = '233'; // this can also be null and will be generated
$success = $q->qlpush('testQueue', json_encode($event), $eventId);
If you're a consumer you can just use the convenience consume method., (*5)
/* the $callback can be any callable:
- array('StaticClass', 'funcName')
- array($obj, 'funcName')
- 'funcName'
- create_function('$event', '...')
*/
$callback = function ($event) use ($q) {
// do anything or nothing at all
return Okq::EVENT_ACK;
};
$timeout = 30;
$q->consume($callback, array('testQueue'), $timeout);