Download the PHP package takuya/php-sysv-ipc-message-queue without Composer
On this page you can find all versions of the php package takuya/php-sysv-ipc-message-queue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-sysv-ipc-message-queue
php-sysv-ipc-message-queue
php sysv ipc message queue wrapper
IPC Message Queue for php
SysV IPC Message queue is available as php function. This package is Object Class wrapping msg_send
.
This repository wrap function and frequently appearing Usage.
Installing
from Packagist.
from GitHub.
Examples.
- Initialize and push
- Dont forget remove Queue.
- Save and Load for system ShutDown.
- Multi process (inter process).
Initialize and push to Queue
initialize and send data to queue.
Since msg_send
is supporting serialize
. we can push everything.
We can get queue message as is sent.
Notice, by serialize() , message size increased.(over 1024, large bytes);
I wrote this class , suppose to be used simple message. large size (>1024) is un-usual way.
Don't forget to remove queue never used.
use destroy()
to remove queue.
Or use ipcs -q
, ipcrm
command to remove unnecessary used queue.
Queue will be remains unless explicitly deleted.
save and load when OS shutdown.
SysV IPC Message will be lost after shutdown. to prevent lost , try save and load messages.
Before shutdown
After restart
Multi Process (IPC)
Multi process (inter process). same name same queue.
consumer.php (worker)
producer.php ( maker )
run
Comparison
PHP's IPC System Message Queue function msg_send
has auto serialization, This is very useful.
Compare SysV IPC Queue to another shared way. IPC Queue is easy to use.
type | advantage to SysV mesg func | dis-advantage to sysV func |
---|---|---|
tcp:// | can listen another pc | Manual serialization, data structure design, read size needs manually adjustment |
Shared-Memory and Semaphore | can share same data | Be careful of R/W timming (Semaphore), manually blocking, Queue Data structure needs fully considered, manually serialization |
File and flock() | data persistence is easy | Be careful of R/W timming(flock), Data structure fully considered, manually serialization |
sqlite / sql | Easy to data persistence | Needs SQL knowledge or O/R mapper, manually serialization |
PHP's SplQueue
or SplStack
cannot share data to another process, These require sql or file library to use.
In that reason, msg_send msg_receive
is the easiest way to share Tasks.