Redis is a useful solution when design systems on server and required the minimum latency between the client and server for handling message. We can easily build a thread application if we use shell_exec based on & and wait. PHP also provides a solution named as pthreads. but unfortunately the pthreads extension cannot be used in a web server environment. Threading in PHP should therefore remain to CLI-based applications only.
To know more about thread application based on the shell script, please refer http://qsok.com/display/KB/Thread+implementation+in+shell+script for more information.
To implement, thread-based redis operation, we need below two functions:
Once you call redis_set() in thread mode, you can wait until your process' done as following:
Below is a practical example to implement Redis application comparing the normal and thread processing :
And below is the result of above code:
The benefit of above example is to enhance its processing performance, so you can do more for your purpose.