PHP Shared Memory

Source: Internet
Author: User

Shared memory is primarily used for interprocess communication

Shared Memory in PHP has two sets of extensions that can be implemented

1,Shmop need to open --enable-shmop parameters when compiling

Instance:

  

$shm _key= Ftok (__file__, ' t ');/** Open a piece of shared memory int $key, string $flags, int $mode, int $size $flags: A: Access read-only memory segment C: Create a new memory segment, or if the memory segment already exists, try to open it for read and write W: Writable memory segment N: Creates a new memory segment that fails if the memory segment already exists $mode: Octal format 0655$size: Data size bytes opened*/$shm _id= Shmop_open ($shm _key, "C", 0644, 1024);/** * Write data data must be in string format, the last point offset * Note: The offset must be within the specified range, otherwise not write **/$size= Shmop_write ($shm _id, ' Songjiankang ', 0);Echo"Write into {$size}";#The read range must also be within the requested memory range, otherwise the failure$data= Shmop_read ($shm _id, 0, 100);Var_dump($data);#Delete Just do a delete flag bit while not allowing the new process process to read and the system will automatically delete when no process is readShmop_delete ($shm _id);#Close the memory segmentShmop_close ($shm _id);

Reference: http://www.laruence.com/2008/04/21/101.html

http://www.yuansir-web.com/2012/09/22/php

PHP Shared Memory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.