Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlo Yatsukhnenko <yatsukhnenko@gmail.com>2022-05-26 18:12:01 +0300
committerPavlo Yatsukhnenko <yatsukhnenko@gmail.com>2022-10-01 13:31:53 +0300
commit144b8b48e230f388e11cbb8cf322e290a278e17e (patch)
tree8ab8cb3b829d8c43f5f2155f7a303ea113468f0b
parentdc9af5296bedef126d2fa7d5ce31181c2824ad94 (diff)
Issue #2106issue-2106
-rw-r--r--common.h1
-rw-r--r--library.c2
-rw-r--r--redis.c9
-rw-r--r--redis.stub.php2
-rw-r--r--redis_arginfo.h7
-rw-r--r--redis_cluster.c4
-rw-r--r--redis_cluster.stub.php2
-rw-r--r--redis_cluster_arginfo.h7
-rw-r--r--redis_cluster_legacy_arginfo.h6
-rw-r--r--redis_legacy_arginfo.h6
-rw-r--r--tests/RedisClusterTest.php1
-rw-r--r--tests/RedisTest.php7
12 files changed, 49 insertions, 5 deletions
diff --git a/common.h b/common.h
index 8af8b541..059bbca0 100644
--- a/common.h
+++ b/common.h
@@ -312,6 +312,7 @@ typedef struct {
int null_mbulk_as_null;
int tcp_keepalive;
int sentinel;
+ size_t txBytes;
} RedisSock;
/* }}} */
diff --git a/library.c b/library.c
index 647b73b3..6d276804 100644
--- a/library.c
+++ b/library.c
@@ -3017,7 +3017,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;
}
diff --git a/redis.c b/redis.c
index 8499d33e..bfb0f8fe 100644
--- a/redis.c
+++ b/redis.c
@@ -3227,6 +3227,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;
diff --git a/redis.stub.php b/redis.stub.php
index ddb55168..05f0aac5 100644
--- a/redis.stub.php
+++ b/redis.stub.php
@@ -180,6 +180,8 @@ class Redis {
public function getTimeout(): int;
+ public function getTransferredBytes(): bool|int;
+
public function hDel(string $key, string $member, string ...$other_members): int;
public function hExists(string $key, string $member): bool;
diff --git a/redis_arginfo.h b/redis_arginfo.h
index e5990f4e..0319ad04 100644
--- a/redis_arginfo.h
+++ b/redis_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 2c5f558917526d1a034a45b63bf7890bd8cb49e5 */
+ * Stub hash: bfb881bc6890b78f10d75c08eb3eb1c2dd4d73b6 */
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")
@@ -306,6 +306,9 @@ ZEND_END_ARG_INFO()
#define arginfo_class_Redis_getTimeout arginfo_class_Redis_dbSize
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_Redis_getTransferredBytes, 0, 0, MAY_BE_BOOL|MAY_BE_LONG)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_hDel, 0, 2, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, member, IS_STRING, 0)
@@ -1057,6 +1060,7 @@ ZEND_METHOD(Redis, getRange);
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);
@@ -1289,6 +1293,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)
diff --git a/redis_cluster.c b/redis_cluster.c
index f163158a..3c1951b9 100644
--- a/redis_cluster.c
+++ b/redis_cluster.c
@@ -1695,6 +1695,10 @@ PHP_METHOD(RedisCluster, clearlasterror) {
RETURN_TRUE;
}
+
+PHP_METHOD(RedisCluster, gettransferredbytes) {
+ CLUSTER_THROW_EXCEPTION("Not implemented", 0);
+}
/* }}} */
/* {{{ proto long RedisCluster::getOption(long option */
diff --git a/redis_cluster.stub.php b/redis_cluster.stub.php
index ed0a8293..c9e762bc 100644
--- a/redis_cluster.stub.php
+++ b/redis_cluster.stub.php
@@ -126,6 +126,8 @@ class RedisCluster {
public function getset(string $key, mixed $value): string;
+ public function gettransferredbytes(): bool|int;
+
public function hdel(string $key, string $member, string ...$other_members): int;
public function hexists(string $key, string $member): bool;
diff --git a/redis_cluster_arginfo.h b/redis_cluster_arginfo.h
index ca606b3c..fc7b03b8 100644
--- a/redis_cluster_arginfo.h
+++ b/redis_cluster_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 7ff59229ef9ab94d3bb918d666610b70a5676030 */
+ * Stub hash: 87b840d3d2a32855dfdc0c6fb7d6cdb542698c0f */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 1)
@@ -258,6 +258,9 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_getset, 0, 2,
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_BOOL|MAY_BE_LONG)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_hdel, 0, 2, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, member, IS_STRING, 0)
@@ -898,6 +901,7 @@ ZEND_METHOD(RedisCluster, getmode);
ZEND_METHOD(RedisCluster, getoption);
ZEND_METHOD(RedisCluster, getrange);
ZEND_METHOD(RedisCluster, getset);
+ZEND_METHOD(RedisCluster, gettransferredbytes);
ZEND_METHOD(RedisCluster, hdel);
ZEND_METHOD(RedisCluster, hexists);
ZEND_METHOD(RedisCluster, hget);
@@ -1092,6 +1096,7 @@ static const zend_function_entry class_RedisCluster_methods[] = {
ZEND_ME(RedisCluster, getoption, arginfo_class_RedisCluster_getoption, ZEND_ACC_PUBLIC)
ZEND_ME(RedisCluster, getrange, arginfo_class_RedisCluster_getrange, 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)
diff --git a/redis_cluster_legacy_arginfo.h b/redis_cluster_legacy_arginfo.h
index 63ebcd73..13379cb9 100644
--- a/redis_cluster_legacy_arginfo.h
+++ b/redis_cluster_legacy_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 7ff59229ef9ab94d3bb918d666610b70a5676030 */
+ * Stub hash: 87b840d3d2a32855dfdc0c6fb7d6cdb542698c0f */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1)
ZEND_ARG_INFO(0, name)
@@ -234,6 +234,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)
@@ -786,6 +788,7 @@ ZEND_METHOD(RedisCluster, getmode);
ZEND_METHOD(RedisCluster, getoption);
ZEND_METHOD(RedisCluster, getrange);
ZEND_METHOD(RedisCluster, getset);
+ZEND_METHOD(RedisCluster, gettransferredbytes);
ZEND_METHOD(RedisCluster, hdel);
ZEND_METHOD(RedisCluster, hexists);
ZEND_METHOD(RedisCluster, hget);
@@ -980,6 +983,7 @@ static const zend_function_entry class_RedisCluster_methods[] = {
ZEND_ME(RedisCluster, getoption, arginfo_class_RedisCluster_getoption, ZEND_ACC_PUBLIC)
ZEND_ME(RedisCluster, getrange, arginfo_class_RedisCluster_getrange, 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)
diff --git a/redis_legacy_arginfo.h b/redis_legacy_arginfo.h
index ebd87a7d..bce7953b 100644
--- a/redis_legacy_arginfo.h
+++ b/redis_legacy_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 2c5f558917526d1a034a45b63bf7890bd8cb49e5 */
+ * Stub hash: bfb881bc6890b78f10d75c08eb3eb1c2dd4d73b6 */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0)
ZEND_ARG_INFO(0, options)
@@ -285,6 +285,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)
@@ -949,6 +951,7 @@ ZEND_METHOD(Redis, getRange);
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);
@@ -1181,6 +1184,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)
diff --git a/tests/RedisClusterTest.php b/tests/RedisClusterTest.php
index 908e1e58..905d1e5c 100644
--- a/tests/RedisClusterTest.php
+++ b/tests/RedisClusterTest.php
@@ -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(); }
diff --git a/tests/RedisTest.php b/tests/RedisTest.php
index 9c06b64e..2653793a 100644
--- a/tests/RedisTest.php
+++ b/tests/RedisTest.php
@@ -5398,6 +5398,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
*/