使用新值在索引处设置列表。
Parameters:
string $key
int $index
string $value
Returns:
如果设置了新值,则为真。如果索引超出范围,或者按键标识的数据类型不是列表,则为FALSE。
Declared in: Redis
Links: https://redis.io/commands/lset
Source:
S:/Software/JetBrains/PHPStorm/App/PhpStorm-2020.2.1.win/plugins/php/lib/php.jar!/stubs/redis/Redis.phplSet
on redis.io
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('10.1.3.15', 6379);
$redis->auth('kuaicdn_redis_passwd');
$redis->flushAll();
$ret['exec'][]=$redis->rPush('list_test','value1');
$ret['exec'][]=$redis->rPush('list_test','value2');
$ret['exec'][]=$redis->rPush('list_test','value3');
$ret['exec'][]=$redis->rPush('list_test','value4');
$ret['cmd'][]=$redis->lRange('list_test',0,-1);
$ret['data'][]=$redis->lSet('list_test',2,'set_value');
$ret['cmd'][]=$redis->lRange('list_test',0,-1);
print_r($ret);
?>
返回值: