common.php 973 B

1234567891011121314151617181920212223242526
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 流年 <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11. // 应用公共文件
  12. function newredis(){
  13. $redis = new Redis();
  14. $redisconfig = config("redis");
  15. $redis->connect($redisconfig["host"], $redisconfig["port"]);
  16. if ($redisconfig['redis_pwd']) {
  17. $redis->auth(config('redis_pwd'));
  18. }
  19. if($redisconfig['redis_selectdb'] > 0){
  20. $redis->select(config('redis_selectdb'));
  21. }
  22. return $redis;
  23. }