Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c8a60a1

Browse files
committed
Replaced SUBSTR with GETRANGE.
1 parent 1929e9b commit c8a60a1

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

README.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ $redis->append('key', 'value2'); /* 12 */
13731373
$redis->get('key'); /* 'value1value2' */
13741374
</pre>
13751375

1376-
## substr
1376+
## getRange (substr also supported but deprecated in redis)
13771377
##### *Description*
13781378
Return a substring of a larger string
13791379

@@ -1388,8 +1388,8 @@ Return a substring of a larger string
13881388
##### *Example*
13891389
<pre>
13901390
$redis->set('key', 'string value');
1391-
$redis->substr('key', 0, 5); /* 'string' */
1392-
$redis->substr('key', -5, -1); /* 'value' */
1391+
$redis->getRange('key', 0, 5); /* 'string' */
1392+
$redis->getRange('key', -5, -1); /* 'value' */
13931393
</pre>
13941394

13951395
## strlen

php_redis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ PHP_METHOD(Redis, decr);
4545
PHP_METHOD(Redis, decrBy);
4646
PHP_METHOD(Redis, type);
4747
PHP_METHOD(Redis, append);
48-
PHP_METHOD(Redis, substr);
48+
PHP_METHOD(Redis, getRange);
4949
PHP_METHOD(Redis, strlen);
5050
PHP_METHOD(Redis, getKeys);
5151
PHP_METHOD(Redis, sort);

redis.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static zend_function_entry redis_functions[] = {
6969
PHP_ME(Redis, decrBy, NULL, ZEND_ACC_PUBLIC)
7070
PHP_ME(Redis, type, NULL, ZEND_ACC_PUBLIC)
7171
PHP_ME(Redis, append, NULL, ZEND_ACC_PUBLIC)
72-
PHP_ME(Redis, substr, NULL, ZEND_ACC_PUBLIC)
72+
PHP_ME(Redis, getRange, NULL, ZEND_ACC_PUBLIC)
7373
PHP_ME(Redis, strlen, NULL, ZEND_ACC_PUBLIC)
7474
PHP_ME(Redis, getKeys, NULL, ZEND_ACC_PUBLIC)
7575
PHP_ME(Redis, sort, NULL, ZEND_ACC_PUBLIC)
@@ -178,6 +178,7 @@ static zend_function_entry redis_functions[] = {
178178
PHP_MALIAS(Redis, zRemove, zDelete, NULL, ZEND_ACC_PUBLIC)
179179
PHP_MALIAS(Redis, zRemoveRangeByScore, zDeleteRangeByScore, NULL, ZEND_ACC_PUBLIC)
180180
PHP_MALIAS(Redis, zSize, zCard, NULL, ZEND_ACC_PUBLIC)
181+
PHP_MALIAS(Redis, substr, getRange, NULL, ZEND_ACC_PUBLIC)
181182
{NULL, NULL, NULL}
182183
};
183184

@@ -1100,7 +1101,7 @@ PHP_METHOD(Redis, append)
11001101
REDIS_PROCESS_RESPONSE(redis_long_response);
11011102
}
11021103

1103-
PHP_METHOD(Redis, substr)
1104+
PHP_METHOD(Redis, getRange)
11041105
{
11051106
zval *object;
11061107
RedisSock *redis_sock;
@@ -1118,7 +1119,7 @@ PHP_METHOD(Redis, substr)
11181119
RETURN_FALSE;
11191120
}
11201121

1121-
cmd_len = redis_cmd_format_static(&cmd, "SUBSTR", "sdd", key, key_len, (int)start, (int)end);
1122+
cmd_len = redis_cmd_format_static(&cmd, "GETRANGE", "sdd", key, key_len, (int)start, (int)end);
11221123
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
11231124
IF_ATOMIC() {
11241125
redis_string_response(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL);

0 commit comments

Comments
 (0)