mirror of
https://github.com/php-win-ext/phpredis.git
synced 2026-03-24 00:52:16 +01:00
Issue #2106
This commit is contained in:
1
common.h
1
common.h
@@ -323,6 +323,7 @@ typedef struct {
|
||||
int null_mbulk_as_null;
|
||||
int tcp_keepalive;
|
||||
int sentinel;
|
||||
size_t txBytes;
|
||||
} RedisSock;
|
||||
/* }}} */
|
||||
|
||||
|
||||
@@ -3128,7 +3128,7 @@ redis_sock_write(RedisSock *redis_sock, char *cmd, size_t sz)
|
||||
if (redis_check_eof(redis_sock, 0, 0) == 0 &&
|
||||
php_stream_write(redis_sock->stream, cmd, sz) == sz
|
||||
) {
|
||||
return sz;
|
||||
return redis_sock->txBytes = sz;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
9
redis.c
9
redis.c
@@ -3131,6 +3131,15 @@ PHP_METHOD(Redis, getDBNum) {
|
||||
}
|
||||
}
|
||||
|
||||
PHP_METHOD(Redis, getTransferredBytes) {
|
||||
RedisSock *redis_sock;
|
||||
|
||||
if ((redis_sock = redis_sock_get_connected(INTERNAL_FUNCTION_PARAM_PASSTHRU)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
RETURN_LONG(redis_sock->txBytes);
|
||||
}
|
||||
|
||||
/* {{{ proto Redis::getTimeout */
|
||||
PHP_METHOD(Redis, getTimeout) {
|
||||
RedisSock *redis_sock;
|
||||
|
||||
@@ -294,6 +294,8 @@ class Redis {
|
||||
|
||||
public function getTimeout(): int;
|
||||
|
||||
public function getTransferredBytes(): int|false;
|
||||
|
||||
public function hDel(string $key, string $member, string ...$other_members): Redis|int|false;
|
||||
|
||||
public function hExists(string $key, string $member): Redis|bool;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 0ff60ed233053935cfc7c5a5ecacd6adaf06a458 */
|
||||
* Stub hash: 894a03b9e9db1e8ded0f016a00e7e7150dc26f31 */
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "null")
|
||||
@@ -359,6 +359,9 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_class_Redis_getTimeout arginfo_class_Redis_getDBNum
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_Redis_getTransferredBytes, 0, 0, MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_hDel, 0, 2, Redis, MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, member, IS_STRING, 0)
|
||||
@@ -1191,6 +1194,7 @@ ZEND_METHOD(Redis, lcs);
|
||||
ZEND_METHOD(Redis, getReadTimeout);
|
||||
ZEND_METHOD(Redis, getset);
|
||||
ZEND_METHOD(Redis, getTimeout);
|
||||
ZEND_METHOD(Redis, getTransferredBytes);
|
||||
ZEND_METHOD(Redis, hDel);
|
||||
ZEND_METHOD(Redis, hExists);
|
||||
ZEND_METHOD(Redis, hGet);
|
||||
@@ -1436,6 +1440,7 @@ static const zend_function_entry class_Redis_methods[] = {
|
||||
ZEND_ME(Redis, getReadTimeout, arginfo_class_Redis_getReadTimeout, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(Redis, getset, arginfo_class_Redis_getset, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(Redis, getTimeout, arginfo_class_Redis_getTimeout, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(Redis, getTransferredBytes, arginfo_class_Redis_getTransferredBytes, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(Redis, hDel, arginfo_class_Redis_hDel, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(Redis, hExists, arginfo_class_Redis_hExists, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(Redis, hGet, arginfo_class_Redis_hGet, ZEND_ACC_PUBLIC)
|
||||
|
||||
@@ -1710,6 +1710,10 @@ PHP_METHOD(RedisCluster, clearlasterror) {
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
PHP_METHOD(RedisCluster, gettransferredbytes) {
|
||||
CLUSTER_THROW_EXCEPTION("Not implemented", 0);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto long RedisCluster::getOption(long option */
|
||||
|
||||
@@ -155,6 +155,8 @@ class RedisCluster {
|
||||
|
||||
public function getset(string $key, mixed $value): RedisCluster|string|bool;
|
||||
|
||||
public function gettransferredbytes(): int|false;
|
||||
|
||||
public function hdel(string $key, string $member, string ...$other_members): RedisCluster|int|false;
|
||||
|
||||
public function hexists(string $key, string $member): RedisCluster|bool;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 3d10a4c161f9a4bcf65ac9acfebbb86d11f9cf0d */
|
||||
* Stub hash: b9d2d6314c74dbf1e80662aa867b36c4a3ecfe8d */
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1)
|
||||
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 1)
|
||||
@@ -306,6 +306,9 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_getset, 0
|
||||
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_RedisCluster_gettransferredbytes, 0, 0, MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_hdel, 0, 2, RedisCluster, MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, member, IS_STRING, 0)
|
||||
@@ -1012,6 +1015,7 @@ ZEND_METHOD(RedisCluster, getoption);
|
||||
ZEND_METHOD(RedisCluster, getrange);
|
||||
ZEND_METHOD(RedisCluster, lcs);
|
||||
ZEND_METHOD(RedisCluster, getset);
|
||||
ZEND_METHOD(RedisCluster, gettransferredbytes);
|
||||
ZEND_METHOD(RedisCluster, hdel);
|
||||
ZEND_METHOD(RedisCluster, hexists);
|
||||
ZEND_METHOD(RedisCluster, hget);
|
||||
@@ -1219,6 +1223,7 @@ static const zend_function_entry class_RedisCluster_methods[] = {
|
||||
ZEND_ME(RedisCluster, getrange, arginfo_class_RedisCluster_getrange, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(RedisCluster, lcs, arginfo_class_RedisCluster_lcs, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(RedisCluster, getset, arginfo_class_RedisCluster_getset, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(RedisCluster, gettransferredbytes, arginfo_class_RedisCluster_gettransferredbytes, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(RedisCluster, hdel, arginfo_class_RedisCluster_hdel, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(RedisCluster, hexists, arginfo_class_RedisCluster_hexists, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(RedisCluster, hget, arginfo_class_RedisCluster_hget, ZEND_ACC_PUBLIC)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 3d10a4c161f9a4bcf65ac9acfebbb86d11f9cf0d */
|
||||
* Stub hash: b9d2d6314c74dbf1e80662aa867b36c4a3ecfe8d */
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, name)
|
||||
@@ -272,6 +272,8 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_class_RedisCluster_getset arginfo_class_RedisCluster_append
|
||||
|
||||
#define arginfo_class_RedisCluster_gettransferredbytes arginfo_class_RedisCluster__masters
|
||||
|
||||
#define arginfo_class_RedisCluster_hdel arginfo_class_RedisCluster_geohash
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_hexists, 0, 0, 2)
|
||||
@@ -864,6 +866,7 @@ ZEND_METHOD(RedisCluster, getoption);
|
||||
ZEND_METHOD(RedisCluster, getrange);
|
||||
ZEND_METHOD(RedisCluster, lcs);
|
||||
ZEND_METHOD(RedisCluster, getset);
|
||||
ZEND_METHOD(RedisCluster, gettransferredbytes);
|
||||
ZEND_METHOD(RedisCluster, hdel);
|
||||
ZEND_METHOD(RedisCluster, hexists);
|
||||
ZEND_METHOD(RedisCluster, hget);
|
||||
@@ -1071,6 +1074,7 @@ static const zend_function_entry class_RedisCluster_methods[] = {
|
||||
ZEND_ME(RedisCluster, getrange, arginfo_class_RedisCluster_getrange, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(RedisCluster, lcs, arginfo_class_RedisCluster_lcs, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(RedisCluster, getset, arginfo_class_RedisCluster_getset, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(RedisCluster, gettransferredbytes, arginfo_class_RedisCluster_gettransferredbytes, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(RedisCluster, hdel, arginfo_class_RedisCluster_hdel, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(RedisCluster, hexists, arginfo_class_RedisCluster_hexists, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(RedisCluster, hget, arginfo_class_RedisCluster_hget, ZEND_ACC_PUBLIC)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 0ff60ed233053935cfc7c5a5ecacd6adaf06a458 */
|
||||
* Stub hash: 894a03b9e9db1e8ded0f016a00e7e7150dc26f31 */
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0)
|
||||
ZEND_ARG_INFO(0, options)
|
||||
@@ -326,6 +326,8 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_class_Redis_getTimeout arginfo_class_Redis___destruct
|
||||
|
||||
#define arginfo_class_Redis_getTransferredBytes arginfo_class_Redis___destruct
|
||||
|
||||
#define arginfo_class_Redis_hDel arginfo_class_Redis_geohash
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_hExists, 0, 0, 2)
|
||||
@@ -1023,6 +1025,7 @@ ZEND_METHOD(Redis, lcs);
|
||||
ZEND_METHOD(Redis, getReadTimeout);
|
||||
ZEND_METHOD(Redis, getset);
|
||||
ZEND_METHOD(Redis, getTimeout);
|
||||
ZEND_METHOD(Redis, getTransferredBytes);
|
||||
ZEND_METHOD(Redis, hDel);
|
||||
ZEND_METHOD(Redis, hExists);
|
||||
ZEND_METHOD(Redis, hGet);
|
||||
@@ -1268,6 +1271,7 @@ static const zend_function_entry class_Redis_methods[] = {
|
||||
ZEND_ME(Redis, getReadTimeout, arginfo_class_Redis_getReadTimeout, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(Redis, getset, arginfo_class_Redis_getset, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(Redis, getTimeout, arginfo_class_Redis_getTimeout, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(Redis, getTransferredBytes, arginfo_class_Redis_getTransferredBytes, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(Redis, hDel, arginfo_class_Redis_hDel, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(Redis, hExists, arginfo_class_Redis_hExists, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(Redis, hGet, arginfo_class_Redis_hGet, ZEND_ACC_PUBLIC)
|
||||
|
||||
@@ -50,6 +50,7 @@ class Redis_Cluster_Test extends Redis_Test {
|
||||
public function testReset() { return $this->markTestSkipped(); }
|
||||
public function testInvalidAuthArgs() { return $this->markTestSkipped(); }
|
||||
public function testScanErrors() { return $this->markTestSkipped(); }
|
||||
public function testTransferredBytes() { return $this->markTestSkipped(); }
|
||||
|
||||
public function testlMove() { return $this->markTestSkipped(); }
|
||||
public function testlPos() { return $this->marktestSkipped(); }
|
||||
|
||||
@@ -5752,6 +5752,13 @@ class Redis_Test extends TestSuite
|
||||
$this->assertTrue($this->redis->getAuth() === $this->getAuth());
|
||||
}
|
||||
|
||||
public function testTransferredBytes() {
|
||||
$this->assertTrue($this->redis->ping());
|
||||
$this->assertEquals(strlen("*1\r\n$4\r\nPING\r\n"), $this->redis->getTransferredBytes());
|
||||
$this->assertEquals(['cluster_enabled' => 0], $this->redis->info('cluster'));
|
||||
$this->assertEquals(strlen("*2\r\n$4\r\nINFO\r\n$7\r\ncluster\r\n"), $this->redis->getTransferredBytes());
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan and variants
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user