在列表的主元值之前或之后插入值。参数选项指定插入的位置(之前或之后)。如果列表不存在,或者主元不存在,则不插入值。
    使用该函数相当于搜索插入
    Parameters:
    string $key
    int $position Redis::BEFORE | Redis::AFTER
    string $pivot
    mixed|string $value
    Returns:
    列表中的元素数,如果主元素不存在,则为-1。
    Declared in: Redis
    Links: https://redis.io/commands/linsert
    Source:
    S:/Software/JetBrains/PHPStorm/App/PhpStorm-2020.2.1.win/plugins/php/lib/php.jar!/stubs/redis/Redis.php
    lInsert 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->rPush('list_test','value1');
    8. $ret['exec'][]=$redis->rPush('list_test','value2');
    9. $ret['exec'][]=$redis->rPush('list_test','value3');
    10. $ret['exec'][]=$redis->rPush('list_test','value4');
    11. $ret['exec'][]=$redis->rPush('list_test','value5');
    12. $ret['cmd']['BEFORE']=$redis->lInsert('list_test',Redis::BEFORE,"value3",'BEFORE');
    13. $ret['cmd']['AFTER']=$redis->lInsert('list_test','AFTER',"value3",'AFTER');
    14. $ret['cmd']['NONE']=$redis->lInsert('list_test','BEFORE',"value6",'NONE');
    15. $ret['src'][]=$redis->lRange('list_test',0,-1);
    16. print_r($ret);
    17. ?>

    返回值:

    1. Array
    2. (
    3. [exec] => Array
    4. (
    5. [0] => 1
    6. [1] => 2
    7. [2] => 3
    8. [3] => 4
    9. [4] => 5
    10. )
    11. [cmd] => Array
    12. (
    13. [BEFORE] => 6
    14. [AFTER] => 7
    15. [NONE] => -1
    16. )
    17. [src] => Array
    18. (
    19. [0] => Array
    20. (
    21. [0] => value1
    22. [1] => value2
    23. [2] => BEFORE
    24. [3] => value3
    25. [4] => AFTER
    26. [5] => value4
    27. [6] => value5
    28. )
    29. )
    30. )