Home>Article>Backend Development> shmop series functions use PHP shared memory implementation method
Shmop, is an easy-to-use feature set that allows PHP to read, write, create and delete UNIX shared memory segments. This article mainly shares with you the implementation method of shmop series functions using PHP shared memory. I hope it can help you.
1、shmop 系列函数使用 value放进共享内存 $message1 = "I love Roverliang"; shm_put_var($shm_id, $share_key, $message1); //重复使用key ,前一个设置的值会被后一个设置的值覆盖掉。 $message2 = "I love Rover"; shm_put_var($shm_id, $share_key, $message2); //读取一个共享内存值 $read_message = shm_get_var($shm_id, $share_key); echo $read_message.PHP_EOL; //并不是取走了,而是读取 $read_message2 = shm_get_var($shm_id, $share_key); echo $read_message2.PHP_EOL; //判断共享内存中,某个值是否存在 $isexists = shm_has_var($shm_id, $share_key); var_dump($isexists); //删除一个值 shm_remove_var($shm_id, $share_key); //判断共享内存中,某个值是否存在 $isexists = shm_has_var($shm_id, $share_key); var_dump($isexists); //删除一个共享内存 shm_remove($shm_id); //关闭共享内存的连接 shm_detach($shm_id);
Related recommendations:
Detailed explanation of the use of PHP shared memory
A preliminary study on php shared memory shmop
The above is the detailed content of shmop series functions use PHP shared memory implementation method. For more information, please follow other related articles on the PHP Chinese website!