<?php //redis 封装 class MyRedis { private static $instance = null; private $redis = null; private function __construct() { $this->redis = new Redis(); $this->redis->connect(config('redis.host'), config('redis.port')); $this->redis->select(config('redis.db')); } public static function getInstance() { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; } public function __call($method, $arguments) { return call_user_func_array([$this->redis, $method], $arguments); } }
07-08