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/

     
  • 相关阅读:
    nvm的安装与使用
    webpack中import动态设置webpackChunkName方法
    css在背景图下加渐变色
    js实现时间戳转换
    js实现随机数和随机数组
    js实现导航自动切换请求数据
    jq、js获取select中option上的value值以及文本值
    js、jq实现select 下拉选择更多
    软件测试
    php
  • 原文地址:https://www.cnblogs.com/newmiracle/p/14457048.html
Copyright © 2011-2022 走看看