用 value 参数覆写给定 key 所储存的字符串值,从偏移量 offset 开始。

    更改较大字符串的子字符串。

    Parameters:
    string $key
    int $offset
    string $value
    Returns:
    字符串被修改后的长度
    Declared in: Redis
    Links: https://redis.io/commands/setrange
    Source:
    S:/Software/JetBrains/PHPStorm/App/PhpStorm-2020.2.1.win/plugins/php/lib/php.jar!/stubs/redis/Redis.php
    setRange on redis.io

    1. <?php
    2. //连接本地的 Redis 服务
    3. $redis = new Redis();
    4. $redis->connect('10.1.3.15', 6379);
    5. $redis->auth('kuaicdn_redis_passwd');
    6. $redis->flushAll();
    7. $ret['exec'][]=$redis->set('list_test','123456789');
    8. $ret['ret'][]=$redis->get('list_test');
    9. $ret['ret'][]=$redis->setRange('list_test',3,'NetValue');
    10. $ret['ret'][]=$redis->get('list_test');
    11. print_r($ret);
    12. ?>

    返回值:

    1. Array
    2. (
    3. [exec] => Array
    4. (
    5. [0] => 1
    6. )
    7. [ret] => Array
    8. (
    9. [0] => 123456789
    10. [1] => 11
    11. [2] => 123NetValue
    12. )
    13. )