PHP 使用 Redis 来做队列服务
<?php class Queue{ protected $redis; protected $key; public function __construct(\Redis $redis, $key) { $this->redis = $redis; $this->key = $key; } public function pop() { return $this->redis->lPop($this->key); // 左边出 } public function push($task) { return $this->redis->rPush($this->key, $task); // 右边入 }}