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/

     
  • 相关阅读:
    D
    NOI 1.7编程基础之字符串(35题)
    HYSBZ 2145 悄悄话
    POJ 2406 Power Strings
    POJ 3461 Oulipo[附KMP算法详细流程讲解]
    POJ 3974 Palindrome
    POJ 1002 487-3279
    POJ 1182 食物链
    POJ 2524 Ubiquitous Religions
    HDU 1251 统计难题
  • 原文地址:https://www.cnblogs.com/newmiracle/p/14457048.html
Copyright © 2011-2022 走看看