use Redis; class RedisTest { const PORT = 6379; /** * redis對象 */ public $redis = null; public function __construct() { $this->redis = new Redis(); $this->redis->connect('127.0.0.1', self::PORT); } public function testPipeline() { $str_constant = get_class($this->redis) . '::PIPELINE'; if (!$str_constant) { return 'pipeline no exit'; } return $this->redis->pipeline()->publish('test', 'pipe-info')->exec(); } }