If you do not need to synchronize the interaction between Java and PHP, I would use memcached , membase, or some other type of memory key storage.
Another way, for a huge amount of data flow, use Unix named pipe (FIFO). This is a common method in IPC (Inter Process Communication). First create the channel as a regular file using the mkfifo command. Add some reasonable permissions. In PHP, open the channel with r+ as a regular file and write, finally close. On the Java side, you keep it open as a regular file and read FileInputStream continuously with a read / readline lock or non-blocking NIO.
Compared to SHM, you donβt have to play with JNI, shared memory synchronization, ring buffer implementation, locking and memory leaks. You get simple read / write and FIFO queues with minimal development costs.
You delete it as a regular file. Do not use random access or seek , as this is a real stream without history.
source share