swoole为什么不建议使用static和global
2024-10-09 21:36:01
$http = new swoole_http_server("0.0.0.0", 9501);
$http->on("request", function ($request, $response) {
static $i;
$i++;
var_dump($i);
$response->end($i); }); $http->start();
你会发现 常驻进程后静态变量不会释放,每个用户访问一次,就加一次。
[root@localhost swoole]# php time.php
^[[15~int(1)
int(2)
int(3)
int(4)
int(5)
int(6)
int(7)
int(8)
int(9)
int(10)
int(11)
int(12)
最新文章
- AFNetworking 3.0 源码解读(四)之 AFURLResponseSerialization
- 利用线上数据验证系统 Gor
- (转载)org.springframework.web.context.ContextLoaderListener
- Redis有序集合Zset(sorted set)
- 2016年11月14日--SQL创建数据库、表-查、插、删、改
- 查询条件Where
- Struts中<;s:checkboxlist>;的用法
- [Everyday Mathematics]20150117
- jQuery表格操作
- gc CMSMaxAbortablePrecleanTime
- 设计模式总结篇系列:享元模式(Flyweight)
- 【C编程基础】make命令和makefile文件
- 刷题之路第三题--Longest Substring Without Repeating Characters
- ADB命令(全)
- mosquitto SSL认证
- CentOS7安装备忘
- Git error: hint: Updates were rejected because the remote contains work that you do hint: not have locally
- o(1), o(n), o(logn), o(nlogn)算法复杂度
- dd-wrt 中继配置
- SqlServer中循环查询结果集