webman 关于数据库性能

webman 关于数据库性能

 

webman链接数据库用的是单例模式 就是用户链接一次 第二次就不需要链接        多个用户就是多个链接1次

 

  public function __construct($pdo, $database = '', $tablePrefix = '', array $config = [])
    {
        print_r('测试链接');
        $this->pdo = $pdo;

        // First we will setup the default properties. We keep track of the DB
        // name we are connected to since it is needed when some reflective
        // type commands are run such as checking whether a table exists.
        $this->database = $database;

        $this->tablePrefix = $tablePrefix;

        $this->config = $config;

        // We need to initialize a query grammar and the query post processors
        // which are both very important parts of the database abstractions
        // so we initialize these to their default values while starting.
        $this->useDefaultQueryGrammar();

        $this->useDefaultPostProcessor();
    }

 

webman链接redis 也是单例  跟数据库方式一样

 public function connect(array $config, array $options)
    {
        print_r('测试链接redis');
        $connector = function () use ($config, $options) {
            return $this->createClient(array_merge(
                $config, $options, Arr::pull($config, 'options', [])
            ));
        };

        return new PhpRedisConnection($connector(), $connector, $config);
    }

 

因为不是携程 不会1个用户会触发2次链接

 

posted @ 2021-02-27 20:19  newmiracle宇宙  阅读(501)  评论(0编辑  收藏  举报