golang new

作者: 分类: go 时间: 2023-02-01 评论: 暂无评论

在 golang 中 new 是另外一种创建变量的方式。通过 new(T) 可以创建 T 类型的变量(这里 T 表示类型),初始值为 T 类型的 零值返回值为其地址 (地址类型是 *T)。

package main

import "fmt"

func newInt1() *int {

return new(int)

}

func newInt2() *int {

var a int
return &a

}

func main() {

p := newInt1()
q := newInt2()
fmt.Println(p, q) // 0xc00001c0b8 0xc00001c0c0

}

PHP函数式编程

作者: 分类: php 时间: 2023-01-16 评论: 暂无评论

PHP函数式编程

 echo '<pre>';
        function memoize($fun){
            $list =[];
            return function($arg)use($fun,&$list){
                $key = md5(json_encode($arg));
                if(!empty($list[$key])){
                    print_r('我是缓存'.PHP_EOL);
                    return $list[$key];
                }
                return $list[$key] =$fun($arg);
            };
        }
        $ff=memoize(function ($r){
            return $r * $r;
        });
        print_r($ff(9999)).PHP_EOL;
        print_r($ff(9999)).PHP_EOL;
        print_r($ff(9999)).PHP_EOL;
        //99980001我是缓存
        //99980001我是缓存
        //99980001

        

原文地址

linux PHP 函数禁用

作者: 分类: php 时间: 2022-11-22 评论: 暂无评论

disable_functions = passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv

putenv 框架使用

linux 检查服务性能,CPU,内存

作者: 分类: php 时间: 2022-11-06 评论: 暂无评论

#检查cpu
ps aux|head -1;ps aux|sort -rn -k +3|head

检查内存

ps aux|head -1;ps aux|sort -rn -k +4|head

检查磁盘 读性能上限

time dd if=/dev/sdb of=/dev/null bs=4k

检查磁盘 写读性能上限

time dd if=/dev/vda1 of=/dev/null bs=4k

当前磁盘IO

iostat -d -k 1 10

apache ab 测试工具 post get 请求

作者: 分类: php 时间: 2022-08-26 评论: 暂无评论
ab -c 100 -n 1000 -T text/html  -p E:\post.txt http://127.0.0.1:9501/notify/index
ab -n 10 -c 10 -p d:\test\querypay.txt -T application/x-www-form-urlencoded http://paycenter.gotrip8.com/querypay.aspx

querypay.txt 里面内容
a=1&b=2

ab -n 10 -c 10 "http://www.baidu.com?searchkey=111"