zoukankan      html  css  js  c++  java
  • 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次链接


    如果遇到什么不懂的地方直接关注公众号留言(本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利。)
    作者:newmiracle
    出处:https://www.cnblogs.com/newmiracle/

     
  • 相关阅读:
    常用和实用的git命令,让你快速入门git
    如何获取电脑的IP和mac地址
    关于vue插件的使用和修改
    BullsEye游戏优化布局
    BullsEye游戏总结
    Android游戏小demo
    算法及相应算法应用之令牌桶算法
    php IDE之phpStorm使用小记
    php中openssl_encrypt方法
    mysql界面工具
  • 原文地址:https://www.cnblogs.com/newmiracle/p/14457048.html
Copyright © 2011-2022 走看看