zoukankan      html  css  js  c++  java
  • TP5连接redis

    config配置

        /*redis链接*/
        'redis' => [
            'default' => [
                'type' => 'redis',
                'debug' => true,
                'hostname' => '127.0.0.1',
                'port' => 6379,
                'auth' => '',
                'timeout' => 3,//单位秒
                'pconnect' => 0,
                'autoconnect' => 0
            ]
        ],
    

    使用

    $arrConfig = Config::get('redis.default');
    $objRedis = new Redis();
    if(!$arrConfig['pconnect'])
        $objRedis->connect($arrConfig['hostname'], $arrConfig['port'],$arrConfig['timeout']);
    else
        $objRedis->pconnect($arrConfig['hostname'], $arrConfig['port'],$arrConfig['timeout']);
    $objRedis->auth($arrConfig['auth']);
    if(!$objRedis) parent::returnCode(1999,'数据库连接失败!');
    return $objRedis;
    
    ##config.php
    /*redis链接*/
        'redis' => [
            'default' => [
                'type' => 'redis',
                'debug' => true,
                'hostname' => '127.0.0.1',
                'port' => 6379,
                'auth' => '',
                'timeout' => 3,//单位秒
                'pconnect' => 0,
                'autoconnect' => 0
            ]
        ],
    
  • 相关阅读:
    WebService
    JavaMail
    ssh框架整合
    CSS3初步
    SpringMVC 文件上传及下载
    Java多线程
    SpringMVC 数据校验
    初始化参数绑定——日期格式
    SpringMVC入门
    Quartz
  • 原文地址:https://www.cnblogs.com/ljkltt/p/14789044.html
Copyright © 2011-2022 走看看