对 key 所储存的字符串值,获取指定偏移量上的位(bit)。
    从较大的字符串中返回一个位

    Parameters:
    string $key
    int $offset
    Returns:
    位值(0或1)

    Declared in: Redis
    Links: https://redis.io/commands/getbit
    Source:
    S:/Software/JetBrains/PHPStorm/App/PhpStorm-2020.2.1.win/plugins/php/lib/php.jar!/stubs/redis/Redis.php
    getBit 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_test1','value1');
    8. $ret['exec'][]=$redis->set('list_test2','value2');
    9. $ret['exec'][]=$redis->set('list_test3','value3');
    10. $ret['exec'][]=$redis->set('list_test4','value4');
    11. $ret['exec'][]=$redis->set('list_test5','hello中国人');
    12. $ret['exec'][]=$redis->set('list_test6','value6',['nx', 'ex' => 10]);
    13. $ret['ret'][]=$redis->get('list_test5');
    14. $ret['ret'][]=$redis->getBit('list_test5',1);
    15. $ret['ret'][]=$redis->getBit('list_test5',2);
    16. $ret['ret'][]=$redis->getBit('list_test5',3);
    17. $ret['ret'][]=$redis->getBit('list_test5',4);
    18. $ret['ret'][]=$redis->getBit('list_test5',5);
    19. $ret['ret'][]=$redis->getBit('list_test5',6);
    20. $ret['ret'][]=$redis->getBit('list_test5',7);
    21. print_r($ret);
    22. ?>

    返回值:

    1. Array
    2. (
    3. [exec] => Array
    4. (
    5. [0] => 1
    6. [1] => 1
    7. [2] => 1
    8. [3] => 1
    9. [4] => 1
    10. [5] => 1
    11. )
    12. [ret] => Array
    13. (
    14. [0] => hello中国人
    15. [1] => 1
    16. [2] => 1
    17. [3] => 0
    18. [4] => 1
    19. [5] => 0
    20. [6] => 0
    21. [7] => 0
    22. )
    23. )

    其实我自己也没看懂,哈哈哈2020-9-28 11:17:58