Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4cd3f59

Browse filesBrowse files
Implement KeyDB's EXPIREMEMBER[AT] commands
1 parent 8144db3 commit 4cd3f59
Copy full SHA for 4cd3f59
Expand file treeCollapse file tree

11 files changed

+204
-9
lines changed

‎redis.c

Copy file name to clipboardExpand all lines: redis.c
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,14 @@ PHP_METHOD(Redis, pexpiretime) {
13791379
REDIS_PROCESS_KW_CMD("PEXPIRETIME", redis_key_cmd, redis_long_response);
13801380
}
13811381

1382+
PHP_METHOD(Redis, expiremember) {
1383+
REDIS_PROCESS_CMD(expiremember, redis_long_response);
1384+
}
1385+
1386+
PHP_METHOD(Redis, expirememberat) {
1387+
REDIS_PROCESS_CMD(expirememberat, redis_long_response);
1388+
}
1389+
13821390
/* }}} */
13831391
/* {{{ proto array Redis::lSet(string key, int index, string value) */
13841392
PHP_METHOD(Redis, lSet) {

‎redis.stub.php

Copy file name to clipboardExpand all lines: redis.stub.php
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,6 +1903,28 @@ public function hVals(string $key): Redis|array|false;
19031903
*/
19041904
public function hscan(string $key, null|int|string &$iterator, ?string $pattern = null, int $count = 0): Redis|array|bool;
19051905

1906+
/**
1907+
* Set an expiration on a key member (KeyDB only).
1908+
*
1909+
* @see https://docs.keydb.dev/docs/commands/#expiremember
1910+
*
1911+
* @param string $key The key to expire
1912+
* @param string $field The field to expire
1913+
* @param string|null $unit The unit of the ttl (s, or ms).
1914+
*/
1915+
public function expiremember(string $key, string $field, int $ttl, ?string $unit = null): Redis|int|false;
1916+
1917+
/**
1918+
* Set an expiration on a key membert to a specific unix timestamp (KeyDB only).
1919+
*
1920+
* @see https://docs.keydb.dev/docs/commands/#expirememberat
1921+
*
1922+
* @param string $key The key to expire
1923+
* @param string $field The field to expire
1924+
* @param int $timestamp The unix timestamp to expire at.
1925+
*/
1926+
public function expirememberat(string $key, string $field, int $timestamp): Redis|int|false;
1927+
19061928
/**
19071929
* Increment a key's value, optionally by a specific amount.
19081930
*

‎redis_arginfo.h

Copy file name to clipboardExpand all lines: redis_arginfo.h
+25-4Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 1cc5fe0df8dfa7d95f2bc45c2383132a68629f24 */
2+
* Stub hash: bacbe6b1d55da4ba6d370fff1090e8de0363c4c2 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0)
55
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null")
@@ -464,6 +464,19 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_hscan, 0, 2, Red
464464
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, count, IS_LONG, 0, "0")
465465
ZEND_END_ARG_INFO()
466466

467+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_expiremember, 0, 3, Redis, MAY_BE_LONG|MAY_BE_FALSE)
468+
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
469+
ZEND_ARG_TYPE_INFO(0, field, IS_STRING, 0)
470+
ZEND_ARG_TYPE_INFO(0, ttl, IS_LONG, 0)
471+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, unit, IS_STRING, 1, "null")
472+
ZEND_END_ARG_INFO()
473+
474+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_expirememberat, 0, 3, Redis, MAY_BE_LONG|MAY_BE_FALSE)
475+
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
476+
ZEND_ARG_TYPE_INFO(0, field, IS_STRING, 0)
477+
ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0)
478+
ZEND_END_ARG_INFO()
479+
467480
#define arginfo_class_Redis_incr arginfo_class_Redis_decr
468481

469482
#define arginfo_class_Redis_incrBy arginfo_class_Redis_decrBy
@@ -1270,6 +1283,8 @@ ZEND_METHOD(Redis, hSetNx);
12701283
ZEND_METHOD(Redis, hStrLen);
12711284
ZEND_METHOD(Redis, hVals);
12721285
ZEND_METHOD(Redis, hscan);
1286+
ZEND_METHOD(Redis, expiremember);
1287+
ZEND_METHOD(Redis, expirememberat);
12731288
ZEND_METHOD(Redis, incr);
12741289
ZEND_METHOD(Redis, incrBy);
12751290
ZEND_METHOD(Redis, incrByFloat);
@@ -1526,6 +1541,8 @@ static const zend_function_entry class_Redis_methods[] = {
15261541
ZEND_ME(Redis, hStrLen, arginfo_class_Redis_hStrLen, ZEND_ACC_PUBLIC)
15271542
ZEND_ME(Redis, hVals, arginfo_class_Redis_hVals, ZEND_ACC_PUBLIC)
15281543
ZEND_ME(Redis, hscan, arginfo_class_Redis_hscan, ZEND_ACC_PUBLIC)
1544+
ZEND_ME(Redis, expiremember, arginfo_class_Redis_expiremember, ZEND_ACC_PUBLIC)
1545+
ZEND_ME(Redis, expirememberat, arginfo_class_Redis_expirememberat, ZEND_ACC_PUBLIC)
15291546
ZEND_ME(Redis, incr, arginfo_class_Redis_incr, ZEND_ACC_PUBLIC)
15301547
ZEND_ME(Redis, incrBy, arginfo_class_Redis_incrBy, ZEND_ACC_PUBLIC)
15311548
ZEND_ME(Redis, incrByFloat, arginfo_class_Redis_incrByFloat, ZEND_ACC_PUBLIC)
@@ -2027,12 +2044,16 @@ static zend_class_entry *register_class_Redis(void)
20272044
zend_string *const_OPT_BACKOFF_CAP_name = zend_string_init_interned("OPT_BACKOFF_CAP", sizeof("OPT_BACKOFF_CAP") - 1, 1);
20282045
zend_declare_class_constant_ex(class_entry, const_OPT_BACKOFF_CAP_name, &const_OPT_BACKOFF_CAP_value, ZEND_ACC_PUBLIC, NULL);
20292046
zend_string_release(const_OPT_BACKOFF_CAP_name);
2030-
#if (PHP_VERSION_ID >= 80200)
2047+
#if (PHP_VERSION_ID >= 80000)
20312048

20322049

2033-
zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "auth", sizeof("auth") - 1), 0, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0);
2050+
zend_string *attribute_name_SensitiveParameter_func_auth_arg0_0 = zend_string_init_interned("SensitiveParameter", sizeof("SensitiveParameter") - 1, 1);
2051+
zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "auth", sizeof("auth") - 1), 0, attribute_name_SensitiveParameter_func_auth_arg0_0, 0);
2052+
zend_string_release(attribute_name_SensitiveParameter_func_auth_arg0_0);
20342053

2035-
zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "migrate", sizeof("migrate") - 1), 7, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0);
2054+
zend_string *attribute_name_SensitiveParameter_func_migrate_arg7_0 = zend_string_init_interned("SensitiveParameter", sizeof("SensitiveParameter") - 1, 1);
2055+
zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "migrate", sizeof("migrate") - 1), 7, attribute_name_SensitiveParameter_func_migrate_arg7_0, 0);
2056+
zend_string_release(attribute_name_SensitiveParameter_func_migrate_arg7_0);
20362057
#endif
20372058

20382059
return class_entry;

‎redis_cluster.c

Copy file name to clipboardExpand all lines: redis_cluster.c
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,14 @@ PHP_METHOD(RedisCluster, getbit) {
13031303
}
13041304
/* }}} */
13051305

1306+
PHP_METHOD(RedisCluster, expiremember) {
1307+
CLUSTER_PROCESS_CMD(expiremember, cluster_long_resp, 0);
1308+
}
1309+
1310+
PHP_METHOD(RedisCluster, expirememberat) {
1311+
CLUSTER_PROCESS_CMD(expiremember, cluster_long_resp, 0);
1312+
}
1313+
13061314
/* {{{ proto long RedisCluster::setbit(string key, long offset, bool onoff) */
13071315
PHP_METHOD(RedisCluster, setbit) {
13081316
CLUSTER_PROCESS_CMD(setbit, cluster_long_resp, 0);

‎redis_cluster.stub.php

Copy file name to clipboardExpand all lines: redis_cluster.stub.php
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,16 @@ public function hmset(string $key, array $key_values): RedisCluster|bool;
495495
*/
496496
public function hscan(string $key, null|int|string &$iterator, ?string $pattern = null, int $count = 0): array|bool;
497497

498+
/**
499+
* @see Redis::expiremember
500+
*/
501+
public function expiremember(string $key, string $field, int $ttl, ?string $unit = null): Redis|int|false;
502+
503+
/**
504+
* @see Redis::expirememberat
505+
*/
506+
public function expirememberat(string $key, string $field, int $timestamp): Redis|int|false;
507+
498508
/**
499509
* @see https://redis.io/commands/hrandfield
500510
*/

‎redis_cluster_arginfo.h

Copy file name to clipboardExpand all lines: redis_cluster_arginfo.h
+22-3Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 5713c5b2f88ddead50088f14026447801120fa33 */
2+
* Stub hash: b9310b607794caa862d509ba316a2a512d2736fe */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 1)
@@ -416,6 +416,19 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_RedisCluster_hscan, 0, 2,
416416
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, count, IS_LONG, 0, "0")
417417
ZEND_END_ARG_INFO()
418418

419+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_expiremember, 0, 3, Redis, MAY_BE_LONG|MAY_BE_FALSE)
420+
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
421+
ZEND_ARG_TYPE_INFO(0, field, IS_STRING, 0)
422+
ZEND_ARG_TYPE_INFO(0, ttl, IS_LONG, 0)
423+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, unit, IS_STRING, 1, "null")
424+
ZEND_END_ARG_INFO()
425+
426+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_expirememberat, 0, 3, Redis, MAY_BE_LONG|MAY_BE_FALSE)
427+
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
428+
ZEND_ARG_TYPE_INFO(0, field, IS_STRING, 0)
429+
ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0)
430+
ZEND_END_ARG_INFO()
431+
419432
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_hrandfield, 0, 1, RedisCluster, MAY_BE_STRING|MAY_BE_ARRAY)
420433
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
421434
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null")
@@ -1135,6 +1148,8 @@ ZEND_METHOD(RedisCluster, hlen);
11351148
ZEND_METHOD(RedisCluster, hmget);
11361149
ZEND_METHOD(RedisCluster, hmset);
11371150
ZEND_METHOD(RedisCluster, hscan);
1151+
ZEND_METHOD(RedisCluster, expiremember);
1152+
ZEND_METHOD(RedisCluster, expirememberat);
11381153
ZEND_METHOD(RedisCluster, hrandfield);
11391154
ZEND_METHOD(RedisCluster, hset);
11401155
ZEND_METHOD(RedisCluster, hsetnx);
@@ -1362,6 +1377,8 @@ static const zend_function_entry class_RedisCluster_methods[] = {
13621377
ZEND_ME(RedisCluster, hmget, arginfo_class_RedisCluster_hmget, ZEND_ACC_PUBLIC)
13631378
ZEND_ME(RedisCluster, hmset, arginfo_class_RedisCluster_hmset, ZEND_ACC_PUBLIC)
13641379
ZEND_ME(RedisCluster, hscan, arginfo_class_RedisCluster_hscan, ZEND_ACC_PUBLIC)
1380+
ZEND_ME(RedisCluster, expiremember, arginfo_class_RedisCluster_expiremember, ZEND_ACC_PUBLIC)
1381+
ZEND_ME(RedisCluster, expirememberat, arginfo_class_RedisCluster_expirememberat, ZEND_ACC_PUBLIC)
13651382
ZEND_ME(RedisCluster, hrandfield, arginfo_class_RedisCluster_hrandfield, ZEND_ACC_PUBLIC)
13661383
ZEND_ME(RedisCluster, hset, arginfo_class_RedisCluster_hset, ZEND_ACC_PUBLIC)
13671384
ZEND_ME(RedisCluster, hsetnx, arginfo_class_RedisCluster_hsetnx, ZEND_ACC_PUBLIC)
@@ -1541,10 +1558,12 @@ static zend_class_entry *register_class_RedisCluster(void)
15411558
zend_string *const_FAILOVER_DISTRIBUTE_SLAVES_name = zend_string_init_interned("FAILOVER_DISTRIBUTE_SLAVES", sizeof("FAILOVER_DISTRIBUTE_SLAVES") - 1, 1);
15421559
zend_declare_class_constant_ex(class_entry, const_FAILOVER_DISTRIBUTE_SLAVES_name, &const_FAILOVER_DISTRIBUTE_SLAVES_value, ZEND_ACC_PUBLIC, NULL);
15431560
zend_string_release(const_FAILOVER_DISTRIBUTE_SLAVES_name);
1544-
#if (PHP_VERSION_ID >= 80200)
1561+
#if (PHP_VERSION_ID >= 80000)
15451562

15461563

1547-
zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "__construct", sizeof("__construct") - 1), 5, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0);
1564+
zend_string *attribute_name_SensitiveParameter_func___construct_arg5_0 = zend_string_init_interned("SensitiveParameter", sizeof("SensitiveParameter") - 1, 1);
1565+
zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "__construct", sizeof("__construct") - 1), 5, attribute_name_SensitiveParameter_func___construct_arg5_0, 0);
1566+
zend_string_release(attribute_name_SensitiveParameter_func___construct_arg5_0);
15481567
#endif
15491568

15501569
return class_entry;

‎redis_cluster_legacy_arginfo.h

Copy file name to clipboardExpand all lines: redis_cluster_legacy_arginfo.h
+18-1Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 5713c5b2f88ddead50088f14026447801120fa33 */
2+
* Stub hash: b9310b607794caa862d509ba316a2a512d2736fe */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1)
55
ZEND_ARG_INFO(0, name)
@@ -368,6 +368,19 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_hscan, 0, 0, 2)
368368
ZEND_ARG_INFO(0, count)
369369
ZEND_END_ARG_INFO()
370370

371+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_expiremember, 0, 0, 3)
372+
ZEND_ARG_INFO(0, key)
373+
ZEND_ARG_INFO(0, field)
374+
ZEND_ARG_INFO(0, ttl)
375+
ZEND_ARG_INFO(0, unit)
376+
ZEND_END_ARG_INFO()
377+
378+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_expirememberat, 0, 0, 3)
379+
ZEND_ARG_INFO(0, key)
380+
ZEND_ARG_INFO(0, field)
381+
ZEND_ARG_INFO(0, timestamp)
382+
ZEND_END_ARG_INFO()
383+
371384
#define arginfo_class_RedisCluster_hrandfield arginfo_class_RedisCluster_getex
372385

373386
#define arginfo_class_RedisCluster_hset arginfo_class_RedisCluster_hincrby
@@ -977,6 +990,8 @@ ZEND_METHOD(RedisCluster, hlen);
977990
ZEND_METHOD(RedisCluster, hmget);
978991
ZEND_METHOD(RedisCluster, hmset);
979992
ZEND_METHOD(RedisCluster, hscan);
993+
ZEND_METHOD(RedisCluster, expiremember);
994+
ZEND_METHOD(RedisCluster, expirememberat);
980995
ZEND_METHOD(RedisCluster, hrandfield);
981996
ZEND_METHOD(RedisCluster, hset);
982997
ZEND_METHOD(RedisCluster, hsetnx);
@@ -1204,6 +1219,8 @@ static const zend_function_entry class_RedisCluster_methods[] = {
12041219
ZEND_ME(RedisCluster, hmget, arginfo_class_RedisCluster_hmget, ZEND_ACC_PUBLIC)
12051220
ZEND_ME(RedisCluster, hmset, arginfo_class_RedisCluster_hmset, ZEND_ACC_PUBLIC)
12061221
ZEND_ME(RedisCluster, hscan, arginfo_class_RedisCluster_hscan, ZEND_ACC_PUBLIC)
1222+
ZEND_ME(RedisCluster, expiremember, arginfo_class_RedisCluster_expiremember, ZEND_ACC_PUBLIC)
1223+
ZEND_ME(RedisCluster, expirememberat, arginfo_class_RedisCluster_expirememberat, ZEND_ACC_PUBLIC)
12071224
ZEND_ME(RedisCluster, hrandfield, arginfo_class_RedisCluster_hrandfield, ZEND_ACC_PUBLIC)
12081225
ZEND_ME(RedisCluster, hset, arginfo_class_RedisCluster_hset, ZEND_ACC_PUBLIC)
12091226
ZEND_ME(RedisCluster, hsetnx, arginfo_class_RedisCluster_hsetnx, ZEND_ACC_PUBLIC)

‎redis_commands.c

Copy file name to clipboardExpand all lines: redis_commands.c
+51Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6079,6 +6079,57 @@ int redis_expire_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
60796079
return SUCCESS;
60806080
}
60816081

6082+
static int
6083+
generic_expiremember_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
6084+
char *kw, size_t kw_len, int has_unit, char **cmd,
6085+
int *cmd_len, short *slot)
6086+
{
6087+
zend_string *key, *mem, *unit = NULL;
6088+
smart_string cmdstr = {0};
6089+
zend_long expiry;
6090+
6091+
ZEND_PARSE_PARAMETERS_START(3, has_unit ? 4 : 3)
6092+
Z_PARAM_STR(key)
6093+
Z_PARAM_STR(mem)
6094+
Z_PARAM_LONG(expiry)
6095+
if (has_unit) {
6096+
Z_PARAM_OPTIONAL
6097+
Z_PARAM_STR_OR_NULL(unit)
6098+
}
6099+
ZEND_PARSE_PARAMETERS_END_EX(return FAILURE);
6100+
6101+
redis_cmd_init_sstr(&cmdstr, 3 + (unit != NULL), kw, kw_len);
6102+
redis_cmd_append_sstr_key_zstr(&cmdstr, key, redis_sock, slot);
6103+
redis_cmd_append_sstr_zstr(&cmdstr, mem);
6104+
redis_cmd_append_sstr_long(&cmdstr, expiry);
6105+
6106+
if (unit != NULL) {
6107+
redis_cmd_append_sstr_zstr(&cmdstr, unit);
6108+
}
6109+
6110+
*cmd = cmdstr.c;
6111+
*cmd_len = cmdstr.len;
6112+
6113+
return SUCCESS;
6114+
}
6115+
6116+
6117+
int redis_expiremember_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
6118+
char **cmd, int *cmd_len, short *slot, void **ctx)
6119+
{
6120+
return generic_expiremember_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU,
6121+
redis_sock, ZEND_STRL("EXPIREMEMBER"), 1,
6122+
cmd, cmd_len, slot);
6123+
}
6124+
6125+
int redis_expirememberat_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
6126+
char **cmd, int *cmd_len, short *slot, void **ctx)
6127+
{
6128+
return generic_expiremember_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU,
6129+
redis_sock, ZEND_STRL("EXPIREMEMBERAT"), 0,
6130+
cmd, cmd_len, slot);
6131+
}
6132+
60826133
int
60836134
redis_sentinel_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
60846135
char *kw, char **cmd, int *cmd_len, short *slot, void **ctx)

‎redis_commands.h

Copy file name to clipboardExpand all lines: redis_commands.h
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,12 @@ int redis_xreadgroup_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
350350
int redis_xtrim_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
351351
char **cmd, int *cmd_len, short *slot, void **ctx);
352352

353+
int redis_expiremember_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
354+
char **cmd, int *cmd_len, short *slot, void **ctx);
355+
356+
int redis_expirememberat_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
357+
char **cmd, int *cmd_len, short *slot, void **ctx);
358+
353359
int redis_lmove_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
354360
char *kw, char **cmd, int *cmd_len, short *slot, void **ctx);
355361

‎redis_legacy_arginfo.h

Copy file name to clipboardExpand all lines: redis_legacy_arginfo.h
+18-1Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 1cc5fe0df8dfa7d95f2bc45c2383132a68629f24 */
2+
* Stub hash: bacbe6b1d55da4ba6d370fff1090e8de0363c4c2 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0)
55
ZEND_ARG_INFO(0, options)
@@ -413,6 +413,19 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_hscan, 0, 0, 2)
413413
ZEND_ARG_INFO(0, count)
414414
ZEND_END_ARG_INFO()
415415

416+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_expiremember, 0, 0, 3)
417+
ZEND_ARG_INFO(0, key)
418+
ZEND_ARG_INFO(0, field)
419+
ZEND_ARG_INFO(0, ttl)
420+
ZEND_ARG_INFO(0, unit)
421+
ZEND_END_ARG_INFO()
422+
423+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_expirememberat, 0, 0, 3)
424+
ZEND_ARG_INFO(0, key)
425+
ZEND_ARG_INFO(0, field)
426+
ZEND_ARG_INFO(0, timestamp)
427+
ZEND_END_ARG_INFO()
428+
416429
#define arginfo_class_Redis_incr arginfo_class_Redis_decr
417430

418431
#define arginfo_class_Redis_incrBy arginfo_class_Redis_append
@@ -1113,6 +1126,8 @@ ZEND_METHOD(Redis, hSetNx);
11131126
ZEND_METHOD(Redis, hStrLen);
11141127
ZEND_METHOD(Redis, hVals);
11151128
ZEND_METHOD(Redis, hscan);
1129+
ZEND_METHOD(Redis, expiremember);
1130+
ZEND_METHOD(Redis, expirememberat);
11161131
ZEND_METHOD(Redis, incr);
11171132
ZEND_METHOD(Redis, incrBy);
11181133
ZEND_METHOD(Redis, incrByFloat);
@@ -1369,6 +1384,8 @@ static const zend_function_entry class_Redis_methods[] = {
13691384
ZEND_ME(Redis, hStrLen, arginfo_class_Redis_hStrLen, ZEND_ACC_PUBLIC)
13701385
ZEND_ME(Redis, hVals, arginfo_class_Redis_hVals, ZEND_ACC_PUBLIC)
13711386
ZEND_ME(Redis, hscan, arginfo_class_Redis_hscan, ZEND_ACC_PUBLIC)
1387+
ZEND_ME(Redis, expiremember, arginfo_class_Redis_expiremember, ZEND_ACC_PUBLIC)
1388+
ZEND_ME(Redis, expirememberat, arginfo_class_Redis_expirememberat, ZEND_ACC_PUBLIC)
13721389
ZEND_ME(Redis, incr, arginfo_class_Redis_incr, ZEND_ACC_PUBLIC)
13731390
ZEND_ME(Redis, incrBy, arginfo_class_Redis_incrBy, ZEND_ACC_PUBLIC)
13741391
ZEND_ME(Redis, incrByFloat, arginfo_class_Redis_incrByFloat, ZEND_ACC_PUBLIC)

‎tests/RedisTest.php

Copy file name to clipboardExpand all lines: tests/RedisTest.php
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,22 @@ public function testMultipleBin() {
716716
$this->redis->mget(array_keys($kvals)));
717717
}
718718

719+
public function testExpireMember() {
720+
if ( ! $this->is_keydb)
721+
$this->markTestSkipped();
722+
723+
$this->redis->del('h');
724+
$this->redis->hmset('h', ['f1' => 'v1', 'f2' => 'v2', 'f3' => 'v3', 'f4' => 'v4']);
725+
726+
$this->assertEquals(1, $this->redis->expiremember('h', 'f1', 1));
727+
$this->assertEquals(1, $this->redis->expiremember('h', 'f2', 1000, 'ms'));
728+
$this->assertEquals(1, $this->redis->expiremember('h', 'f3', 1000, null));
729+
$this->assertEquals(0, $this->redis->expiremember('h', 'nk', 10));
730+
731+
$this->assertEquals(1, $this->redis->expirememberat('h', 'f4', time() + 1));
732+
$this->assertEquals(0, $this->redis->expirememberat('h', 'nk', time() + 1));
733+
}
734+
719735
public function testExpire() {
720736
$this->redis->del('key');
721737
$this->redis->set('key', 'value');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.