php response.status,src/Response/Status.php · 青黄直落/predis - Gitee.com

"PredisResponseStatus类是Redis响应接口的实现,用于表示Redis返回的状态响应。此类缓存了常见的如'OK'和'QUEUED'等状态,以减少内存使用,特别是当使用管道操作时。构造函数接收Redis返回的响应负载,并提供了获取负载的方法。"
摘要由CSDN通过智能技术生成

/*

* This file is part of the Predis package.

*

* (c) Daniele Alessandri

*

* For the full copyright and license information, please view the LICENSE

* file that was distributed with this source code.

*/

namespace Predis\Response;

/**

* Represents a status response returned by Redis.

*

* @author Daniele Alessandri

*/

class Status implements ResponseInterface

{

private static $OK;

private static $QUEUED;

private $payload;

/**

* @param string $payload Payload of the status response as returned by Redis.

*/

public function __construct($payload)

{

$this->payload = $payload;

}

/**

* Converts the response object to its string representation.

*

* @return string

*/

public function __toString()

{

return $this->payload;

}

/**

* Returns the payload of status response.

*

* @return string

*/

public function getPayload()

{

return $this->payload;

}

/**

* Returns an instance of a status response object.

*

* Common status responses such as OK or QUEUED are cached in order to lower

* the global memory usage especially when using pipelines.

*

* @param string $payload Status response payload.

*

* @return string

*/

public static function get($payload)

{

switch ($payload) {

case 'OK':

case 'QUEUED':

if (isset(self::$$payload)) {

return self::$$payload;

}

return self::$$payload = new self($payload);

default:

return new self($payload);

}

}

}

一键复制

编辑

Web IDE

原始数据

按行查看

历史

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值