@@ -976,6 +976,41 @@ ra_move_list(const char *key, int key_len, zval *z_from, zval *z_to TSRMLS_DC) {
976
976
return ra_move_collection (key , key_len , z_from , z_to , 3 , cmd_list , 1 , cmd_add TSRMLS_CC );
977
977
}
978
978
979
+ static zend_bool
980
+ ra_expire_key (const char * key , int key_len , zval * z_from , zval * z_to TSRMLS_DC ) {
981
+
982
+ zval z_fun_ttl , z_fun_expire , z_ret , * z_args [2 ];
983
+ long ttl ;
984
+
985
+ /* run TTL on source */
986
+ MAKE_STD_ZVAL (z_args [0 ]);
987
+ ZVAL_STRINGL (& z_fun_ttl , "TTL" , 3 , 0 );
988
+ ZVAL_STRINGL (z_args [0 ], key , key_len , 0 );
989
+ call_user_function (& redis_ce -> function_table , & z_from , & z_fun_ttl , & z_ret , 1 , z_args TSRMLS_CC );
990
+
991
+ if (Z_TYPE (z_ret ) != IS_LONG ) {
992
+ efree (z_args [0 ]);
993
+ return 0 ;
994
+ }
995
+
996
+ ttl = Z_LVAL (z_ret );
997
+ zval_dtor (& z_ret );
998
+ if (ttl > 0 )
999
+ {
1000
+ /* run EXPIRE on target */
1001
+ MAKE_STD_ZVAL (z_args [1 ]);
1002
+ ZVAL_STRINGL (& z_fun_expire , "EXPIRE" , 6 , 0 );
1003
+ ZVAL_STRINGL (z_args [0 ], key , key_len , 0 );
1004
+ ZVAL_LONG (z_args [1 ], ttl );
1005
+ call_user_function (& redis_ce -> function_table , & z_to , & z_fun_expire , & z_ret , 2 , z_args TSRMLS_CC );
1006
+ efree (z_args [1 ]);
1007
+ }
1008
+ /* cleanup */
1009
+ efree (z_args [0 ]);
1010
+
1011
+ return 1 ;
1012
+ }
1013
+
979
1014
void
980
1015
ra_move_key (const char * key , int key_len , zval * z_from , zval * z_to TSRMLS_DC ) {
981
1016
@@ -1012,6 +1047,7 @@ ra_move_key(const char *key, int key_len, zval *z_from, zval *z_to TSRMLS_DC) {
1012
1047
}
1013
1048
1014
1049
if (success ) {
1050
+ ra_expire_key (key , key_len , z_from , z_to TSRMLS_CC );
1015
1051
ra_del_key (key , key_len , z_from TSRMLS_CC );
1016
1052
ra_index_key (key , key_len , z_to TSRMLS_CC );
1017
1053
}
0 commit comments