Home > php教程 > php手册 > PHP共享内存段

PHP共享内存段

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:54:30
Original
1074 people have browsed it

在asp.net和java中都有共享内存,php除了可以使用Memcached等方式变通以外其实php也是支持共享内存的! 需要安装扩展shmop 找到php安装源文件目录 # cd /usr/local/php-5.4.0/ext/shmop # /usr/local/php/bin/phpize # ./configure --with-php-config=/usr/l

在asp.net和java中都有共享内存,php除了可以使用Memcached等方式变通以外其实php也是支持共享内存的!

 

需要安装扩展shmop

找到php安装源文件目录

# cd /usr/local/php-5.4.0/ext/shmop

# /usr/local/php/bin/phpize

# ./configure --with-php-config=/usr/local/php/bin/php-config

#  make && make install

编译安装成功

PHP共享内存段

# cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/

多出一个 shmop.so

在php.ini增加shmop.so

extension=shmop.so
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;

phpinfo()输出

PHP共享内存段

写数据

<?php $shmid = shmop_open(864, 'c', 0755, 1024);
shmop_write($shmid, "Hello World!", 0);
phpinfo();
?>
Copy after login


读数据

<?php $shmid = shmop_open(864, 'c', 0755, 1024);
shmop_write($shmid, "Hello World!", 0);
echo shmop_read($shmid, 0, 11);
?>
Copy after login


 

 

参考:http://www.ibm.com/developerworks/cn/opensource/os-php-shared-memory/
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template